結果

問題 No.3086 Re One Two
ユーザー Leal-0
提出日時 2025-04-04 23:27:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,059 bytes
コンパイル時間 2,221 ms
コンパイル使用メモリ 195,892 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-04 23:28:03
合計ジャッジ時間 6,951 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef INCLUDED_MAIN
#define INCLUDED_MAIN

#include __FILE__

int main() {
    ll n; cin>>n;
    vector<bool> islocked(n,false);
    vector<ll> nxt(n,-1);
    ll twopos=-100;
    rep(i,n) {
        ll a,b; cin>>a>>b;
        if(a==1) {
            islocked[i]=true;
            nxt[i+1]=i;
        }
        if(b==1) nxt[i]=twopos;
        if(b==2) {
            islocked[i]=true;
            twopos=i;
        }
    }
    rep(i,n) {
        if(!islocked[i]) {
            cout<<i+1<<nl;
            ll cur=i;
            while(nxt[cur]!=-1) {
                cur=nxt[cur];
                cout<<cur+1<<nl;
            }
        }
    }
}

/////// library zone ///////
#else
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define srep(i,l,r) for(ll i=l;i<=r;i++)
using ll = long long;
const ll mod=998244353;
#define vout(v) for(auto i :v) cout<<i<<" ";
#define INF 9223300000000000000ll
#define Winf 5e12
#define nl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vl vector<ll>


#endif
0