結果
問題 | No.2325 Skill Tree |
ユーザー |
|
提出日時 | 2023-05-28 14:34:34 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 913 bytes |
コンパイル時間 | 348 ms |
コンパイル使用メモリ | 81,664 KB |
実行使用メモリ | 124,476 KB |
最終ジャッジ日時 | 2024-12-27 02:04:29 |
合計ジャッジ時間 | 28,889 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 WA * 19 |
ソースコード
import bisectN = int(input())needLV = [-1 for i in range(0,N+1)]needLV[1] = 0data = {}LV = [0,0]for i in range(1,N+1):data[i] = []for i in range(N-1):L,A = map(int,input().split())data[A].append(i+2)LV.append(L)#print(data)nex = [1]visited = [0 for i in range(0,N+1)]while nex != []:nex2 = []for i in nex:visited[i] = 1for j in data[i]:if visited[j] == 0:needLV[j] = max(LV[i],LV[j])nex2.append(j)nex = nex2.copy()Q = int(input())bisect_lis = []for i in range(0,len(needLV)):if needLV[i] == -1:bisect_lis.append(10**10)else:bisect_lis.append(needLV[i])bisect_lis = sorted(bisect_lis)for i in range(Q):num,sub = map(int,input().split())if num == 1:print(bisect.bisect_right(bisect_lis,sub))else:print(needLV[sub])