結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
![]() |
提出日時 | 2017-12-24 15:58:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 269 ms / 5,000 ms |
コード長 | 472 bytes |
コンパイル時間 | 801 ms |
コンパイル使用メモリ | 72,980 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-17 18:33:52 |
合計ジャッジ時間 | 2,077 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <sstream> #include <cmath> #include <stack> using namespace std; int main() { int n =0; cin>>n; int pair[n] ={}; string s; cin>>s; stack<int> p; for(int i=0; i<s.length(); i++){ if(s[i] == '('){ p.push(i); } if(s[i] == ')'){ pair[p.top()] =i+1; pair[i] = p.top()+1; p.pop(); } } for(int i=0; i<s.length(); i++){ cout<<pair[i]<<endl; } return 0; }