結果
| 問題 | No.3086 Re One Two | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-04-04 21:26:58 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 256 ms / 2,000 ms | 
| コード長 | 467 bytes | 
| コンパイル時間 | 949 ms | 
| コンパイル使用メモリ | 82,564 KB | 
| 実行使用メモリ | 92,852 KB | 
| 最終ジャッジ日時 | 2025-04-04 21:27:16 | 
| 合計ジャッジ時間 | 10,102 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 32 | 
ソースコード
n = int(input())
A = []
B = []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
nex = [-1] * n
j = -1
tf = [True] * n
for i in range(n - 1, -1, -1):
    if B[i] == 2:
        nex[j] = i
        tf[i] = False
    elif B[i] == 1:
        j = i
    if A[i] == 1:
        nex[i + 1] = i
        tf[i] = False
for i in range(n):
    if tf[i]:
        x = i
        while x != -1:
            print(x + 1)
            x = nex[x]
            
            
            
        