結果

問題 No.2325 Skill Tree
ユーザー tontirutontiru
提出日時 2023-05-28 14:46:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,013 ms / 3,000 ms
コード長 923 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 130,228 KB
最終ジャッジ日時 2023-08-27 10:34:57
合計ジャッジ時間 31,575 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,140 KB
testcase_01 AC 68 ms
70,920 KB
testcase_02 AC 66 ms
71,440 KB
testcase_03 AC 66 ms
71,128 KB
testcase_04 AC 66 ms
71,128 KB
testcase_05 AC 66 ms
71,136 KB
testcase_06 AC 66 ms
71,260 KB
testcase_07 AC 444 ms
83,296 KB
testcase_08 AC 360 ms
96,900 KB
testcase_09 AC 480 ms
90,604 KB
testcase_10 AC 424 ms
109,496 KB
testcase_11 AC 490 ms
99,040 KB
testcase_12 AC 845 ms
124,820 KB
testcase_13 AC 829 ms
124,620 KB
testcase_14 AC 822 ms
124,672 KB
testcase_15 AC 847 ms
124,756 KB
testcase_16 AC 804 ms
124,612 KB
testcase_17 AC 805 ms
124,784 KB
testcase_18 AC 795 ms
125,160 KB
testcase_19 AC 797 ms
125,028 KB
testcase_20 AC 795 ms
125,076 KB
testcase_21 AC 803 ms
125,004 KB
testcase_22 AC 809 ms
124,972 KB
testcase_23 AC 802 ms
124,652 KB
testcase_24 AC 803 ms
124,816 KB
testcase_25 AC 809 ms
124,772 KB
testcase_26 AC 803 ms
124,776 KB
testcase_27 AC 980 ms
128,788 KB
testcase_28 AC 968 ms
127,080 KB
testcase_29 AC 967 ms
126,656 KB
testcase_30 AC 986 ms
128,268 KB
testcase_31 AC 1,013 ms
130,228 KB
testcase_32 AC 913 ms
128,032 KB
testcase_33 AC 912 ms
127,680 KB
testcase_34 AC 922 ms
127,904 KB
testcase_35 AC 962 ms
127,572 KB
testcase_36 AC 932 ms
127,140 KB
testcase_37 AC 964 ms
127,928 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