結果

問題 No.3086 Re One Two
ユーザー timi
提出日時 2025-04-04 22:00:28
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 587 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 425,752 KB
最終ジャッジ日時 2025-04-04 22:00:36
合計ジャッジ時間 4,306 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 1 TLE * 1 -- * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
from collections import deque
d=deque()
A=[deque() for i in range(N)] 
for i in range(N):
  A[i].append(i+1)
  
d=deque()
ans=[]
for i in range(N):
  a,b=map(int,input().split())
  if a+b==0:
    while A[i]:
      c=A[i].popleft()
      ans.append(c)
  elif b==2:
    while A[i]:
      c=A[i].popleft()
      d.append(c)
  if b==1:
    while d:
      c=d.popleft()
      A[i].append(c)
  if a==1:
    while A[i]:
      c=A[i].popleft()
      A[i+1].append(c)
      
for i in range(N):
  while A[i]:
    c=A[i].popleft()
    ans.append(c)
    
for c in ans:
  print(c)
    
0