結果
問題 | No.592 括弧の対応 (2) |
ユーザー | squid |
提出日時 | 2017-11-10 23:36:00 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 262 ms / 5,000 ms |
コード長 | 456 bytes |
コンパイル時間 | 638 ms |
コンパイル使用メモリ | 60,340 KB |
実行使用メモリ | 4,500 KB |
最終ジャッジ日時 | 2023-08-16 05:31:36 |
合計ジャッジ時間 | 2,182 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 262 ms
4,380 KB |
testcase_02 | AC | 261 ms
4,500 KB |
testcase_03 | AC | 256 ms
4,376 KB |
ソースコード
#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; }