結果

問題 No.2325 Skill Tree
ユーザー nikoro256nikoro256
提出日時 2023-05-28 14:22:35
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,095 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 150,580 KB
最終ジャッジ日時 2023-08-27 09:39:54
合計ジャッジ時間 72,260 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
71,776 KB
testcase_01 AC 99 ms
71,504 KB
testcase_02 AC 99 ms
71,760 KB
testcase_03 AC 99 ms
71,624 KB
testcase_04 AC 100 ms
71,660 KB
testcase_05 AC 99 ms
71,640 KB
testcase_06 AC 98 ms
71,760 KB
testcase_07 AC 806 ms
88,772 KB
testcase_08 AC 790 ms
107,832 KB
testcase_09 AC 1,017 ms
101,460 KB
testcase_10 AC 1,084 ms
128,408 KB
testcase_11 AC 1,160 ms
112,536 KB
testcase_12 AC 2,129 ms
149,792 KB
testcase_13 AC 2,088 ms
149,556 KB
testcase_14 AC 2,135 ms
149,036 KB
testcase_15 AC 2,190 ms
149,404 KB
testcase_16 AC 2,166 ms
149,620 KB
testcase_17 AC 1,550 ms
150,220 KB
testcase_18 AC 1,570 ms
149,820 KB
testcase_19 AC 1,543 ms
150,156 KB
testcase_20 AC 1,557 ms
149,560 KB
testcase_21 AC 1,548 ms
150,580 KB
testcase_22 AC 2,577 ms
149,284 KB
testcase_23 AC 2,629 ms
149,568 KB
testcase_24 AC 2,611 ms
149,372 KB
testcase_25 AC 2,630 ms
149,040 KB
testcase_26 AC 2,590 ms
149,552 KB
testcase_27 AC 2,795 ms
142,128 KB
testcase_28 AC 2,828 ms
142,528 KB
testcase_29 AC 2,775 ms
141,924 KB
testcase_30 AC 2,784 ms
143,076 KB
testcase_31 AC 2,835 ms
143,452 KB
testcase_32 AC 2,095 ms
142,516 KB
testcase_33 AC 2,176 ms
141,244 KB
testcase_34 AC 2,194 ms
141,152 KB
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
N=int(input())
lis=[]
for i in range(N-1):
    L,A=map(int,input().split())
    lis.append([L,A,i+2])
lis.sort()
use=[False for _ in range(N+2)]
sets=[set() for _ in range(N+2)]
use[1]=True
nums=[-1 for _ in range(N+2)]
count=[0 for _ in range(N+2)]
from collections import deque
for l,a,ind in lis:
    if use[a]:
        i=ind-2
        use[ind]=True
        nums[ind]=l
        dq=deque()
        dq.append(ind)
        while len(dq)!=0:
            p=dq.popleft()
            for s in sets[p]:
                use[s]=True
                nums[s]=l
                dq.append(s)
    else:
        sets[a].add(ind)

import bisect
point=[0 for _ in range(len(lis)+1)]
for i in range(2,N+1):
    if nums[i]!=-1:
        point[bisect.bisect_left(lis,[nums[i]])]+=1
for i in range(1,len(point)):
    point[i]+=point[i-1]
point.append(0)
for i in range(len(point)):
    point[i]+=1
Q=int(input())
for _ in range(Q):
    q=list(map(int,input().split()))
    if q[0]==2:
        print(nums[q[1]])
    if q[0]==1:
        print(point[bisect.bisect_right(lis,[q[1],10**9])-1])
        pass
0