結果
| 問題 | No.3086 Re One Two | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-04-03 22:08:13 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 310 ms / 2,000 ms | 
| コード長 | 827 bytes | 
| コンパイル時間 | 1,107 ms | 
| コンパイル使用メモリ | 92,064 KB | 
| 実行使用メモリ | 7,720 KB | 
| 最終ジャッジ日時 | 2025-04-03 22:08:25 | 
| 合計ジャッジ時間 | 11,320 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 32 | 
ソースコード
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
using ll = long long;
int main(){
    int N;
    cin >> N;
    vector<bool> lock(N,0);
    vector<int> to(N,-1);
    int two = -1;
    for(int i = 0; i < N; i++){
        int A,B;
        cin >> A >> B;
        if(A == 1){
            lock[i] = 1;
            to[i+1] = i;
        }
        if(B == 1){
            to[i] = two;
        }
        if(B == 2){
            lock[i] = 1;
            two = i;
        }
    }
    stack<int> sta;
    for(int i = 0; i < N; i++){
        if(!lock[i]){
            sta.push(i);
            while(sta.size()){
                int now = sta.top();
                sta.pop();
                cout << now + 1 << endl;
                if(to[now] != -1)sta.push(to[now]);
            }
        }
    }
    return 0;
}
            
            
            
        