結果

問題 No.2325 Skill Tree
ユーザー dangodango
提出日時 2023-06-13 21:24:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 993 ms / 3,000 ms
コード長 540 bytes
コンパイル時間 1,173 ms
コンパイル使用メモリ 85,320 KB
実行使用メモリ 107,512 KB
最終ジャッジ日時 2023-09-04 08:31:13
合計ジャッジ時間 32,981 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,500 KB
testcase_01 AC 94 ms
71,320 KB
testcase_02 AC 96 ms
71,324 KB
testcase_03 AC 99 ms
71,496 KB
testcase_04 AC 95 ms
71,416 KB
testcase_05 AC 95 ms
71,580 KB
testcase_06 AC 96 ms
71,584 KB
testcase_07 AC 491 ms
82,484 KB
testcase_08 AC 373 ms
88,452 KB
testcase_09 AC 527 ms
86,120 KB
testcase_10 AC 440 ms
96,768 KB
testcase_11 AC 535 ms
90,828 KB
testcase_12 AC 855 ms
105,216 KB
testcase_13 AC 849 ms
104,876 KB
testcase_14 AC 846 ms
104,908 KB
testcase_15 AC 882 ms
104,928 KB
testcase_16 AC 832 ms
105,024 KB
testcase_17 AC 815 ms
104,940 KB
testcase_18 AC 815 ms
104,872 KB
testcase_19 AC 804 ms
104,788 KB
testcase_20 AC 811 ms
104,932 KB
testcase_21 AC 814 ms
105,048 KB
testcase_22 AC 852 ms
104,860 KB
testcase_23 AC 845 ms
104,804 KB
testcase_24 AC 847 ms
104,916 KB
testcase_25 AC 852 ms
104,976 KB
testcase_26 AC 839 ms
104,884 KB
testcase_27 AC 993 ms
107,140 KB
testcase_28 AC 985 ms
107,064 KB
testcase_29 AC 973 ms
106,468 KB
testcase_30 AC 985 ms
107,372 KB
testcase_31 AC 975 ms
107,092 KB
testcase_32 AC 913 ms
107,332 KB
testcase_33 AC 916 ms
107,160 KB
testcase_34 AC 910 ms
107,336 KB
testcase_35 AC 980 ms
107,512 KB
testcase_36 AC 970 ms
107,116 KB
testcase_37 AC 978 ms
107,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect, collections
N = int(input())
E = [[] for _ in range(N)]
TEMP = [1]
for i in range(1, N):
  Li, Ai = map(int, input().split())
  TEMP.append(Li)
  E[Ai - 1].append(i)
INFINITY = 1 << 30
L = [INFINITY] * N
L[0] = 1
D = collections.deque([0])
while D:
  U = D.popleft()
  for V in E[U]:
    L[V] = max(TEMP[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] < INFINITY else -1)
0