結果

問題 No.2325 Skill Tree
ユーザー tontirutontiru
提出日時 2023-05-28 14:34:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 913 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 86,784 KB
実行使用メモリ 127,636 KB
最終ジャッジ日時 2023-08-27 10:08:15
合計ジャッジ時間 30,964 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,064 KB
testcase_01 AC 78 ms
71,308 KB
testcase_02 WA -
testcase_03 AC 77 ms
71,300 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 78 ms
71,156 KB
testcase_07 AC 478 ms
82,976 KB
testcase_08 AC 385 ms
96,592 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 534 ms
98,892 KB
testcase_12 AC 873 ms
124,444 KB
testcase_13 AC 872 ms
124,428 KB
testcase_14 AC 871 ms
124,492 KB
testcase_15 WA -
testcase_16 AC 857 ms
124,492 KB
testcase_17 AC 844 ms
124,852 KB
testcase_18 AC 844 ms
124,672 KB
testcase_19 AC 842 ms
124,852 KB
testcase_20 WA -
testcase_21 AC 843 ms
124,720 KB
testcase_22 AC 871 ms
124,488 KB
testcase_23 WA -
testcase_24 AC 863 ms
124,300 KB
testcase_25 AC 869 ms
124,408 KB
testcase_26 AC 869 ms
124,576 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
N = int(input())

needLV = [-1 for i in range(0,N+1)]
needLV[1] = 0
data = {}
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] = 1
        for 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])

0