結果

問題 No.2325 Skill Tree
ユーザー ntudantuda
提出日時 2023-06-05 21:41:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 889 ms / 3,000 ms
コード長 679 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 86,368 KB
実行使用メモリ 101,432 KB
最終ジャッジ日時 2023-08-28 09:44:26
合計ジャッジ時間 28,654 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,168 KB
testcase_01 AC 71 ms
71,480 KB
testcase_02 AC 70 ms
71,208 KB
testcase_03 AC 71 ms
71,312 KB
testcase_04 AC 70 ms
71,240 KB
testcase_05 AC 72 ms
71,076 KB
testcase_06 AC 70 ms
71,320 KB
testcase_07 AC 455 ms
81,616 KB
testcase_08 AC 332 ms
87,112 KB
testcase_09 AC 470 ms
84,344 KB
testcase_10 AC 394 ms
93,572 KB
testcase_11 AC 463 ms
88,272 KB
testcase_12 AC 754 ms
99,164 KB
testcase_13 AC 769 ms
99,208 KB
testcase_14 AC 762 ms
99,028 KB
testcase_15 AC 765 ms
100,004 KB
testcase_16 AC 740 ms
99,208 KB
testcase_17 AC 754 ms
99,396 KB
testcase_18 AC 731 ms
99,128 KB
testcase_19 AC 751 ms
99,156 KB
testcase_20 AC 726 ms
98,996 KB
testcase_21 AC 743 ms
99,396 KB
testcase_22 AC 799 ms
99,996 KB
testcase_23 AC 763 ms
100,004 KB
testcase_24 AC 748 ms
99,396 KB
testcase_25 AC 729 ms
99,348 KB
testcase_26 AC 762 ms
100,652 KB
testcase_27 AC 883 ms
101,088 KB
testcase_28 AC 866 ms
101,084 KB
testcase_29 AC 857 ms
100,832 KB
testcase_30 AC 883 ms
101,068 KB
testcase_31 AC 886 ms
101,280 KB
testcase_32 AC 800 ms
100,980 KB
testcase_33 AC 822 ms
101,340 KB
testcase_34 AC 857 ms
100,840 KB
testcase_35 AC 889 ms
101,076 KB
testcase_36 AC 878 ms
101,432 KB
testcase_37 AC 879 ms
101,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = [[] for _ in range(N + 1)]  # S[i]:= iを覚えていると思えられる技のリスト
L = [0] * (N + 1)  # L[i]:= 技iを覚えるのに必要なレベル
L[1] = 1
L1 = [-1] * (N + 1)
L1[1] = 1
for i in range(2, N + 1):
    l, s = map(int, input().split())
    S[s].append(i)
    L[i] = l
q = [1]
while q:
    x = q.pop(-1)
    for y in S[x]:
        L1[y] = max(L1[x], L[y])
        q.append(y)

L2 = L1[:]
L2.sort()
from bisect import *

x = bisect_left(L2, 0)
L2 = L2[x:]

# print(L)
# print(L2)

Q = int(input())
for _ in range(Q):
    t, x = map(int, input().split())
    if t == 1:
        print(bisect_right(L2, x))
    else:
        print(L1[x])
0