結果

問題 No.2325 Skill Tree
ユーザー sepa38sepa38
提出日時 2023-04-15 14:04:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 962 ms / 3,000 ms
コード長 521 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 82,348 KB
実行使用メモリ 105,092 KB
最終ジャッジ日時 2024-04-19 08:33:00
合計ジャッジ時間 29,400 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,888 KB
testcase_01 AC 42 ms
53,632 KB
testcase_02 AC 41 ms
54,016 KB
testcase_03 AC 41 ms
53,760 KB
testcase_04 AC 41 ms
53,740 KB
testcase_05 AC 41 ms
53,760 KB
testcase_06 AC 43 ms
53,760 KB
testcase_07 AC 454 ms
80,896 KB
testcase_08 AC 330 ms
87,384 KB
testcase_09 AC 484 ms
84,352 KB
testcase_10 AC 399 ms
95,292 KB
testcase_11 AC 495 ms
89,520 KB
testcase_12 AC 823 ms
104,800 KB
testcase_13 AC 808 ms
105,052 KB
testcase_14 AC 825 ms
105,044 KB
testcase_15 AC 820 ms
104,784 KB
testcase_16 AC 812 ms
104,672 KB
testcase_17 AC 794 ms
105,000 KB
testcase_18 AC 781 ms
104,788 KB
testcase_19 AC 790 ms
105,092 KB
testcase_20 AC 806 ms
105,040 KB
testcase_21 AC 803 ms
104,780 KB
testcase_22 AC 829 ms
104,788 KB
testcase_23 AC 808 ms
104,524 KB
testcase_24 AC 856 ms
104,800 KB
testcase_25 AC 814 ms
104,912 KB
testcase_26 AC 818 ms
105,044 KB
testcase_27 AC 955 ms
104,000 KB
testcase_28 AC 962 ms
103,536 KB
testcase_29 AC 936 ms
102,880 KB
testcase_30 AC 944 ms
103,056 KB
testcase_31 AC 954 ms
104,480 KB
testcase_32 AC 889 ms
103,172 KB
testcase_33 AC 939 ms
103,132 KB
testcase_34 AC 935 ms
103,368 KB
testcase_35 AC 931 ms
103,292 KB
testcase_36 AC 918 ms
103,448 KB
testcase_37 AC 948 ms
103,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
from collections import deque
n = int(input())
e = [[] for _ in range(n)]
tmp = [1]
for i in range(1, n):
  li, ai = map(int, input().split())
  tmp.append(li)
  e[ai-1].append(i)
inf = 1 << 30
l = [inf] * n
l[0] = 1
d = deque([0])
while d:
  u = d.popleft()
  for v in e[u]:
    l[v] = max(tmp[v], l[u])
    d.append(v)
sl = sorted(l)
for _ in range(int(input())):
  t, x = list(map(int, input().split()))
  if t == 1:
    print(bisect.bisect_right(sl, x))
  else:
    print(l[x-1] if l[x-1] < inf else -1)
0