結果
| 問題 | No.592 括弧の対応 (2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-05 12:26:28 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 269 ms / 5,000 ms |
| コード長 | 493 bytes |
| 記録 | |
| コンパイル時間 | 618 ms |
| コンパイル使用メモリ | 71,924 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-28 01:41:37 |
| 合計ジャッジ時間 | 2,428 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#include<iostream>
#include<stack>
using namespace std;
int main(){
stack<int> st;
int n;
cin >> n;
int A[n+1] = {};
string s;
cin >> s;
for(int i = 0; i < n; i++){
if(s[i] == '('){
st.push(i+1);
}else if(s[i] == ')'){
int firstPos = st.top(); st.pop();
A[i+1] = firstPos;
A[firstPos] = i+1;
}
}
for(int i = 1; i <= n; i++){
cout << A[i] << endl;
}
return 0;
}