結果

問題 No.3086 Re One Two
ユーザー nasutarou1341
提出日時 2025-04-04 21:45:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 82,040 KB
実行使用メモリ 121,624 KB
最終ジャッジ日時 2025-04-04 21:45:38
合計ジャッジ時間 10,268 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

L  = []
for i in range(N):
  a, b = AB[i]
  if a == 1:
    L.append([b, i + 1])
    continue
  if b == 2:
    L.append([2, i + 1])
    continue
  print(i + 1)
  if len(L) == 0: continue
  if b != 1 and L[-1][0] == 2: continue
  if b == 1:
    t = 1
  else:
    t = 0
  for j in range(len(L)):
    n, x = L.pop()
    if n == 2 and t == 0:
      L.append([n, x])
      break
    if n == 2: t -= 1
    if n == 1: t += 1
    print(x)
0