結果
問題 | No.592 括弧の対応 (2) |
ユーザー | squid |
提出日時 | 2017-11-10 23:36:00 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 268 ms / 5,000 ms |
コード長 | 456 bytes |
コンパイル時間 | 674 ms |
コンパイル使用メモリ | 61,268 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 15:41:12 |
合計ジャッジ時間 | 1,949 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include<iostream> #include<stack> using namespace std; int n; string s; int h[200001]; stack<int> kakko; int main(){ cin>>n>>s; for(int i=0; i<n; i++){ int a=i+1; int b; if(s[i]=='('){ kakko.push(a); } else{ b=kakko.top(); kakko.pop(); h[a]=b; h[b]=a; } } for(int i=1; i<=n; i++){ cout<<h[i]<<endl; } return 0; }