結果
問題 | No.592 括弧の対応 (2) |
ユーザー | ohreitetsu |
提出日時 | 2017-11-12 17:16:13 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 742 ms / 5,000 ms |
コード長 | 587 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 58,852 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-16 10:57:59 |
合計ジャッジ時間 | 2,402 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 742 ms
4,380 KB |
testcase_02 | AC | 257 ms
4,376 KB |
testcase_03 | AC | 261 ms
4,380 KB |
ソースコード
#include <iostream> #include <string> #include <vector> using namespace std; int main(int argc, char* argv[]) { string s; int sLen; cin>>sLen; cin>>s; vector<int> aw(sLen,0); int i=0; int LeftIndex=0; int LeftNum=0; while (sLen>0){ if (s[i]=='('){ LeftIndex=i; LeftNum++; }else if (s[i]==')'){ LeftNum--; aw[LeftIndex]=i; aw[i]=LeftIndex; s[LeftIndex]=' '; s[i]=' '; sLen-=2; if (LeftNum>0){ while (LeftIndex>0 && s[LeftIndex]==' '){ LeftIndex--; } } } i++; } for (i=0;i<aw.size();i++){ cout<<aw[i]+1<<endl; } return 0; }