結果

問題 No.2325 Skill Tree
ユーザー tontirutontiru
提出日時 2023-05-29 11:55:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,037 ms / 3,000 ms
コード長 923 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 130,288 KB
最終ジャッジ日時 2023-08-27 23:39:37
合計ジャッジ時間 34,255 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,116 KB
testcase_01 AC 75 ms
71,180 KB
testcase_02 AC 75 ms
71,216 KB
testcase_03 AC 73 ms
71,148 KB
testcase_04 AC 77 ms
71,396 KB
testcase_05 AC 76 ms
71,308 KB
testcase_06 AC 75 ms
71,204 KB
testcase_07 AC 458 ms
83,088 KB
testcase_08 AC 376 ms
96,352 KB
testcase_09 AC 513 ms
90,500 KB
testcase_10 AC 442 ms
109,312 KB
testcase_11 AC 557 ms
98,916 KB
testcase_12 AC 859 ms
124,712 KB
testcase_13 AC 865 ms
124,420 KB
testcase_14 AC 854 ms
124,716 KB
testcase_15 AC 809 ms
124,520 KB
testcase_16 AC 827 ms
124,732 KB
testcase_17 AC 791 ms
124,992 KB
testcase_18 AC 803 ms
125,092 KB
testcase_19 AC 806 ms
125,220 KB
testcase_20 AC 799 ms
124,748 KB
testcase_21 AC 787 ms
124,900 KB
testcase_22 AC 794 ms
124,512 KB
testcase_23 AC 816 ms
124,588 KB
testcase_24 AC 826 ms
124,756 KB
testcase_25 AC 802 ms
124,616 KB
testcase_26 AC 807 ms
124,960 KB
testcase_27 AC 959 ms
128,824 KB
testcase_28 AC 972 ms
127,100 KB
testcase_29 AC 959 ms
126,740 KB
testcase_30 AC 965 ms
128,172 KB
testcase_31 AC 982 ms
130,288 KB
testcase_32 AC 966 ms
127,860 KB
testcase_33 AC 922 ms
127,624 KB
testcase_34 AC 904 ms
127,776 KB
testcase_35 AC 1,037 ms
127,608 KB
testcase_36 AC 937 ms
127,040 KB
testcase_37 AC 978 ms
127,840 KB
権限があれば一括ダウンロードができます

ソースコード

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],needLV[i])
                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