結果

問題 No.2325 Skill Tree
ユーザー tyawanmusityawanmusi
提出日時 2023-05-24 12:02:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,688 ms / 3,000 ms
コード長 796 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 89,352 KB
最終ジャッジ日時 2023-08-25 03:31:45
合計ジャッジ時間 74,691 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,216 KB
testcase_01 AC 17 ms
8,340 KB
testcase_02 AC 16 ms
8,132 KB
testcase_03 AC 17 ms
8,308 KB
testcase_04 AC 16 ms
8,216 KB
testcase_05 AC 17 ms
8,216 KB
testcase_06 AC 17 ms
8,316 KB
testcase_07 AC 905 ms
18,964 KB
testcase_08 AC 756 ms
41,000 KB
testcase_09 AC 1,092 ms
30,840 KB
testcase_10 AC 1,032 ms
63,444 KB
testcase_11 AC 1,185 ms
47,284 KB
testcase_12 AC 2,253 ms
87,600 KB
testcase_13 AC 2,280 ms
87,648 KB
testcase_14 AC 2,280 ms
87,548 KB
testcase_15 AC 2,264 ms
87,532 KB
testcase_16 AC 2,273 ms
87,652 KB
testcase_17 AC 2,209 ms
87,732 KB
testcase_18 AC 2,192 ms
87,720 KB
testcase_19 AC 2,190 ms
87,644 KB
testcase_20 AC 2,203 ms
87,672 KB
testcase_21 AC 2,234 ms
87,596 KB
testcase_22 AC 2,310 ms
87,600 KB
testcase_23 AC 2,291 ms
87,540 KB
testcase_24 AC 2,310 ms
87,584 KB
testcase_25 AC 2,266 ms
87,548 KB
testcase_26 AC 2,276 ms
87,720 KB
testcase_27 AC 2,669 ms
89,344 KB
testcase_28 AC 2,630 ms
89,352 KB
testcase_29 AC 2,673 ms
88,948 KB
testcase_30 AC 2,688 ms
89,164 KB
testcase_31 AC 2,636 ms
89,216 KB
testcase_32 AC 2,555 ms
89,260 KB
testcase_33 AC 2,670 ms
89,152 KB
testcase_34 AC 2,566 ms
89,292 KB
testcase_35 AC 2,669 ms
89,220 KB
testcase_36 AC 2,650 ms
89,224 KB
testcase_37 AC 2,674 ms
89,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#1個前の提出はassertの条件を間違えています
from bisect import bisect_right
n=int(input())
assert 2<=n<=2*10**5
lp=[list(map(int,input().split())) for _ in range(n-1)]
cil=[[]for _ in range(n)]
for i in range(1,n):
    l,p=lp[i-1]
    assert 1<=l<=10**9
    assert 1<=p<=n and p!=i+1
    cil[p-1].append((i,l))
level=[10**10]*n
level[0]=0
sta=[0]
for node in sta:
    for mode,l in cil[node]:
        level[mode]=max(level[node],l)
        sta.append(mode)
level_s=sorted(level)
q=int(input())
assert 1<=q<=2*10**5
for _ in range(q):
    q,xy=map(int, input().split())
    assert q==1 or q==2
    if q==1:
        assert 1<=xy<=10**9
        print(bisect_right(level_s,xy))
    else:
        assert 2<=xy<=n
        if level[xy-1]==10**10:print(-1)
        else:print(level[xy-1])
0