結果

問題 No.3086 Re One Two
ユーザー Kude
提出日時 2025-04-04 21:42:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 101,856 KB
最終ジャッジ日時 2025-04-04 21:42:47
合計ジャッジ時間 8,781 ms
ジャッジサーバーID
(参考情報)
judge6 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    ai, bi = map(int, input().split())
    a[i] = ai
    b[i] = bi
ans = []
jump = [-1] * n
for i in range(n):
    if a[i] == 1:
        jump[i+1] = i
    elif b[i] == 2:
        j = i
        while b[j] != 1:
            j += 1
        jump[j] = i
    else:
        ans.append(i + 1)
        while jump[i] != -1:
            i = jump[i]
            ans.append(i + 1)
print(*ans, sep='\n')
0