結果
問題 |
No.3086 Re One Two
|
ユーザー |
|
提出日時 | 2025-04-04 21:45:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 385 ms / 2,000 ms |
コード長 | 1,391 bytes |
コンパイル時間 | 704 ms |
コンパイル使用メモリ | 81,524 KB |
実行使用メモリ | 123,516 KB |
最終ジャッジ日時 | 2025-04-04 21:45:28 |
合計ジャッジ時間 | 12,360 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
from sys import stdin,setrecursionlimit#,set_int_max_str_digits #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') setrecursionlimit(20000000) # これこどふぉだと無理 #set_int_max_str_digits(200010) mod = 998244353 ii = lambda :int(stdin.readline()) mi = lambda :map(int,stdin.readline().split()) li = lambda :list(mi()) gmi = lambda :map(lambda x: int(x) - 1, stdin.readline().split()) gi = lambda :list(map(lambda x: 0 if x == "." else 1,input())) # グリッド入力受け取り py = lambda :print("Yes") pn = lambda :print("No") pf = lambda :print("First") ps = lambda :print("Second") vec = [(1,0),(-1,0),(0,-1),(0,1)] vec1 = [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)] #8方向 inf = 2*10**18 from collections import defaultdict from heapq import heappop,heapify n = ii() que = [i for i in range(n)] heapify(que) data = [li() for _ in range(n)] nxt = dict() pre = [] for i in range(n): pos = heappop(que) if data[pos][0] == 1: nxt[pos+1] = pos continue if data[pos][1] == 2: pre.append(pos) continue print(pos+1) while True: if data[pos][1] == 1: pos = pre.pop() print(pos+1) continue if pos in nxt: pos = nxt[pos] print(pos+1) continue else: break