結果
問題 | No.3086 Re One Two |
ユーザー |
![]() |
提出日時 | 2025-04-04 22:33:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 302 ms / 2,000 ms |
コード長 | 545 bytes |
コンパイル時間 | 339 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 143,820 KB |
最終ジャッジ日時 | 2025-04-04 22:33:49 |
合計ジャッジ時間 | 10,998 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
from collections import defaultdict from bisect import bisect_left, bisect_right N = int(input()) ans = [] d = {} bs1 = [] xs = [] for i in range(N): A, B = map(int, input().split()) if B == 1: bs1.append(i) xs.append((A, B)) for i, (a, b) in enumerate(xs): if a == 1: d[i+1] = i elif b == 2: j = bisect_left(bs1, i+1) d[bs1[j]] = i else: ans.append(i) t = i while t in d: ans.append(d[t]) t = d[t] print(*[x+1 for x in ans], sep='\n')