結果
| 問題 | No.3756 Udon Network |
| ユーザー |
tsunamayo123
|
| 提出日時 | 2026-09-11 20:02:59 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 1,155 bytes |
| 記録 | |
| コンパイル時間 | 62 ms |
| コンパイル使用メモリ | 81,488 KB |
| 実行使用メモリ | 305,764 KB |
| 最終ジャッジ日時 | 2026-10-09 17:39:53 |
| 合計ジャッジ時間 | 14,850 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge2_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| Example | 0 % | AC * 8 |
| Subtask $1$ | 2 % | AC * 15 |
| Subtask $2$ | 4 % | AC * 22 |
| Subtask $3$ | 8 % | AC * 3 TLE * 1 -- * 5 |
| Subtask $4$ | 16 % | AC * 2 -- * 8 |
| Subtask $5$ | 32 % | AC * 3 -- * 7 |
| Subtask $6$ | 38 % | AC * 22 TLE * 1 -- * 30 |
| 合計 | 4 * 6% = 24 点 |
ソースコード
# 部分点2
import sys
from collections import deque
input = sys.stdin.readline
N,M,Q = map(int, input().split())
A = list(map(int, input().split()))
A = [x-1 for x in A]
G = [[] for _ in range(N)]
W = {0} # 答えは0かw_jなので、添字で二分探索できる
for i in range(M):
u,v,w = map(int, input().split())
G[u-1].append((v-1,w))
G[v-1].append((u-1,w))
W.add(w)
W = sorted(W)
for i in range(Q):
s,c = map(int, input().split())
s-=1
ok=len(W)
ng=-1
while(ok-ng>1):
mid = (ok+ng)//2
D=W[mid]
visited = [0]*N
flag = [0]*N
visited[s]=True
flag[A[s]]=True
que = deque([s])
while que:
m=que.popleft()
for nex,w in G[m]:
if ((w<=D) and visited[nex]==False):
visited[nex]=True
flag[A[nex]]=True
que.append(nex)
t=0
for l in range(N):
if flag[l]:
t+=1
if t>=c:
ok=mid
else:
ng=mid
if ok == len(W):
print(-1)
else:
print(W[ok])
tsunamayo123