結果
問題 | No.2325 Skill Tree |
ユーザー | 👑 p-adic |
提出日時 | 2023-05-29 01:22:00 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 706 bytes |
コンパイル時間 | 433 ms |
コンパイル使用メモリ | 87,136 KB |
実行使用メモリ | 172,536 KB |
最終ジャッジ日時 | 2023-08-27 18:34:45 |
合計ジャッジ時間 | 21,863 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
75,684 KB |
testcase_01 | AC | 75 ms
71,116 KB |
testcase_02 | AC | 77 ms
71,304 KB |
testcase_03 | AC | 71 ms
71,124 KB |
testcase_04 | AC | 72 ms
71,224 KB |
testcase_05 | AC | 71 ms
71,260 KB |
testcase_06 | AC | 70 ms
71,248 KB |
testcase_07 | AC | 388 ms
104,736 KB |
testcase_08 | AC | 376 ms
104,452 KB |
testcase_09 | AC | 435 ms
111,660 KB |
testcase_10 | AC | 473 ms
115,260 KB |
testcase_11 | AC | 481 ms
118,488 KB |
testcase_12 | AC | 760 ms
151,112 KB |
testcase_13 | AC | 766 ms
150,944 KB |
testcase_14 | AC | 763 ms
150,784 KB |
testcase_15 | AC | 770 ms
149,592 KB |
testcase_16 | AC | 762 ms
151,144 KB |
testcase_17 | AC | 650 ms
126,320 KB |
testcase_18 | AC | 645 ms
126,228 KB |
testcase_19 | AC | 649 ms
126,100 KB |
testcase_20 | AC | 644 ms
126,196 KB |
testcase_21 | AC | 647 ms
126,108 KB |
testcase_22 | AC | 806 ms
169,632 KB |
testcase_23 | AC | 795 ms
172,536 KB |
testcase_24 | AC | 786 ms
170,152 KB |
testcase_25 | AC | 784 ms
165,604 KB |
testcase_26 | AC | 800 ms
166,528 KB |
testcase_27 | TLE | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
ソースコード
I,R=input,range def S(n): return int(n)-1 def J(): return map(S,I().split()) N=int(I()) p,w=[i for i in R(N)],[0]*N def r(i): m=p[i] while i!=m: p[i]=i=p[m] m=p[i] return i E,L=[set() for i in R(N)],[0]*N for i in R(1,N): L[i],A=J() E[A].add(i) A,B=r(A),r(i) if w[B]<w[A]:A,B=B,A if w[A]==w[B]:w[B]+=1 p[A]=B n={0} while len(n): i=n.pop() for e in E[i]:L[e]=max(L[e],L[i]) n|=E[i] Q=int(I()) t,y,X=[0]*Q,[0]*Q,set() for i in R(Q): t[i],y[i]=J() if 1-t[i]:X.add(y[i]) D,d,m,e={},0,[{0},set()],0 for x in sorted(X): n=m[e] while len(n): i=n.pop() if L[i]>x:m[1-e].add(i) else:d,n=d+1,n|E[i] D[x],e=d,1-e z=r(0) for i in R(Q):print([-1,L[y[i]]+1][r(y[i])==z] if t[i] else D[y[i]])