結果

問題 No.2325 Skill Tree
ユーザー kemunikukemuniku
提出日時 2023-05-28 13:48:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 932 ms / 3,000 ms
コード長 658 bytes
コンパイル時間 1,621 ms
コンパイル使用メモリ 85,972 KB
実行使用メモリ 124,732 KB
最終ジャッジ日時 2023-08-27 08:30:13
合計ジャッジ時間 29,131 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
70,984 KB
testcase_01 AC 71 ms
71,148 KB
testcase_02 AC 73 ms
71,108 KB
testcase_03 AC 71 ms
70,924 KB
testcase_04 AC 72 ms
71,052 KB
testcase_05 AC 72 ms
70,996 KB
testcase_06 AC 71 ms
70,876 KB
testcase_07 AC 481 ms
83,540 KB
testcase_08 AC 360 ms
96,372 KB
testcase_09 AC 500 ms
90,568 KB
testcase_10 AC 431 ms
109,232 KB
testcase_11 AC 500 ms
100,444 KB
testcase_12 AC 818 ms
123,468 KB
testcase_13 AC 811 ms
123,640 KB
testcase_14 AC 813 ms
123,312 KB
testcase_15 AC 819 ms
124,732 KB
testcase_16 AC 816 ms
123,336 KB
testcase_17 AC 781 ms
123,152 KB
testcase_18 AC 792 ms
123,248 KB
testcase_19 AC 786 ms
123,164 KB
testcase_20 AC 792 ms
122,900 KB
testcase_21 AC 783 ms
123,152 KB
testcase_22 AC 811 ms
124,368 KB
testcase_23 AC 814 ms
124,200 KB
testcase_24 AC 811 ms
124,404 KB
testcase_25 AC 815 ms
123,440 KB
testcase_26 AC 824 ms
123,332 KB
testcase_27 AC 925 ms
118,232 KB
testcase_28 AC 909 ms
118,040 KB
testcase_29 AC 914 ms
117,348 KB
testcase_30 AC 932 ms
117,524 KB
testcase_31 AC 919 ms
117,780 KB
testcase_32 AC 874 ms
117,976 KB
testcase_33 AC 865 ms
118,440 KB
testcase_34 AC 881 ms
118,024 KB
testcase_35 AC 914 ms
117,972 KB
testcase_36 AC 905 ms
118,236 KB
testcase_37 AC 923 ms
118,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
P = [-1]*N
Gout = [set() for i in range(N)]
LEVEL = [10**18]*N
Llist = [-1]*N
Llist[0] = 0
LEVEL[0] = 0
for i in range(1,N):
    L,A = map(int,input().split())
    P[i] = A-1
    Gout[A-1].add(i)
    Llist[i] = L
stack = [0]

while stack:
    i = stack.pop()
    for j in Gout[i]:
        LEVEL[j] = max(Llist[j],LEVEL[i])
        stack.append(j)
needlevel = LEVEL[:]
needlevel.sort()
import bisect
Q = int(input())
for i in range(Q):
    x,y = map(int,input().split())
    if x == 1:
        print(bisect.bisect_right(needlevel,y))
    else:
        if LEVEL[y-1] == 10**18:
            print(-1)
        else:
            print(LEVEL[y-1])
0