結果
問題 |
No.592 括弧の対応 (2)
|
ユーザー |
|
提出日時 | 2017-11-11 23:43:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 5,000 ms |
コード長 | 340 bytes |
コンパイル時間 | 574 ms |
コンパイル使用メモリ | 74,900 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-24 19:33:43 |
合計ジャッジ時間 | 1,168 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <stack> using namespace std; int main(){ int n,k; cin>>n; string s; cin>>s; vector<int>v(s.size()); stack<int>st; for(int i=0;i<s.size();i++){ if(s[i]=='(')st.push(i); else{ int x=st.top();st.pop(); v[x]=i,v[i]=x; } } for(auto &e:v)printf("%d\n",e+1); }