結果

問題 No.2325 Skill Tree
ユーザー ああいいああいい
提出日時 2023-06-01 09:11:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,079 ms / 3,000 ms
コード長 786 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 122,672 KB
最終ジャッジ日時 2023-08-28 01:53:16
合計ジャッジ時間 29,407 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,312 KB
testcase_01 AC 71 ms
71,196 KB
testcase_02 AC 72 ms
71,196 KB
testcase_03 AC 72 ms
71,488 KB
testcase_04 AC 70 ms
71,220 KB
testcase_05 AC 73 ms
71,172 KB
testcase_06 AC 72 ms
71,404 KB
testcase_07 AC 450 ms
82,492 KB
testcase_08 AC 343 ms
89,724 KB
testcase_09 AC 469 ms
86,732 KB
testcase_10 AC 418 ms
98,400 KB
testcase_11 AC 486 ms
92,856 KB
testcase_12 AC 783 ms
111,784 KB
testcase_13 AC 797 ms
111,972 KB
testcase_14 AC 793 ms
112,232 KB
testcase_15 AC 813 ms
111,464 KB
testcase_16 AC 768 ms
111,644 KB
testcase_17 AC 779 ms
112,064 KB
testcase_18 AC 779 ms
111,720 KB
testcase_19 AC 782 ms
112,032 KB
testcase_20 AC 774 ms
111,488 KB
testcase_21 AC 783 ms
111,876 KB
testcase_22 AC 787 ms
111,232 KB
testcase_23 AC 765 ms
110,980 KB
testcase_24 AC 785 ms
112,032 KB
testcase_25 AC 754 ms
111,856 KB
testcase_26 AC 775 ms
111,932 KB
testcase_27 AC 979 ms
121,112 KB
testcase_28 AC 1,079 ms
122,672 KB
testcase_29 AC 902 ms
121,732 KB
testcase_30 AC 936 ms
120,696 KB
testcase_31 AC 913 ms
120,976 KB
testcase_32 AC 878 ms
122,180 KB
testcase_33 AC 873 ms
122,356 KB
testcase_34 AC 907 ms
122,096 KB
testcase_35 AC 887 ms
121,736 KB
testcase_36 AC 879 ms
120,852 KB
testcase_37 AC 875 ms
121,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
L = [0]
A = [-1]
G = [[] for _ in range(N)]

for _ in range(N - 1):
    l,a = map(int,input().split())
    L.append(l)
    A.append(a - 1)
    G[a-1].append(_ + 1)

Q = int(input())
inf = 10 ** 10

level = [-1] * N
level[0] = 0

stack = [0]
while stack:
    now = stack.pop()
    for v in G[now]:
        level[v] = max(level[now],L[v])
        stack.append(v)
u = []
for j in level:
    if j != -1:u.append(j)
u.sort()
for _ in range(Q):
    i,t = map(int,input().split())
    x = t
    y = t
    if i == 1:
        end = len(u)
        start = 0
        while end - start > 1:
            mid = end + start >> 1
            if u[mid] <= x:
                start = mid
            else:
                end = mid
        print(end)
    else:
        print(level[y-1])
0