結果
問題 |
No.3086 Re One Two
|
ユーザー |
![]() |
提出日時 | 2025-04-04 21:49:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 69 ms / 2,000 ms |
コード長 | 874 bytes |
コンパイル時間 | 4,755 ms |
コンパイル使用メモリ | 280,720 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-04-04 21:50:05 |
合計ジャッジ時間 | 8,042 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; template <class T> using V=vector<T>; template <class T> using VV=V<V<T>>; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; V<int> A(n),B(n); rep(i,n) cin>>A[i]>>B[i]; V<int> to(n,-1),ANS; stack<int> st; rep(i,n){ if(A[i]==1){ to[i+1]=i; continue; } if(B[i]==2){ st.push(i); continue; } ANS.push_back(i); int now=i; while(1){ if(to[now]!=-1){ now=to[now]; ANS.push_back(now); continue; } if(B[now]==1){ auto a=st.top(); st.pop(); now=a; ANS.push_back(now); continue; } break; } } rep(i,n) cout<<ANS[i]+1<<'\n'; return 0; }