結果

問題 No.2325 Skill Tree
ユーザー ああいいああいい
提出日時 2023-06-01 09:10:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 753 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 114,344 KB
最終ジャッジ日時 2023-08-28 01:52:32
合計ジャッジ時間 29,624 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,248 KB
testcase_01 WA -
testcase_02 AC 73 ms
71,036 KB
testcase_03 WA -
testcase_04 AC 72 ms
71,336 KB
testcase_05 AC 75 ms
71,252 KB
testcase_06 AC 72 ms
71,272 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 786 ms
113,492 KB
testcase_18 AC 786 ms
113,484 KB
testcase_19 AC 785 ms
113,384 KB
testcase_20 AC 779 ms
113,460 KB
testcase_21 AC 771 ms
113,500 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 889 ms
110,160 KB
testcase_28 AC 930 ms
110,344 KB
testcase_29 AC 889 ms
108,920 KB
testcase_30 AC 905 ms
109,428 KB
testcase_31 AC 885 ms
109,512 KB
testcase_32 AC 850 ms
109,936 KB
testcase_33 AC 867 ms
109,232 KB
testcase_34 AC 882 ms
109,552 KB
testcase_35 AC 859 ms
109,356 KB
testcase_36 AC 864 ms
109,448 KB
testcase_37 AC 870 ms
109,316 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 = level.copy()
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