結果
| 問題 |
No.592 括弧の対応 (2)
|
| コンテスト | |
| ユーザー |
femto
|
| 提出日時 | 2017-11-10 22:23:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 237 ms / 5,000 ms |
| コード長 | 464 bytes |
| コンパイル時間 | 1,687 ms |
| コンパイル使用メモリ | 170,956 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-24 12:10:08 |
| 合計ジャッジ時間 | 2,624 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans[200000];
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
#ifdef LOCAL
std::ifstream in("in");
std::cin.rdbuf(in.rdbuf());
#endif
int N;
string s;
cin >> N >> s;
stack<int> st;
for(int i = 0; i < N; i++){
if(s[i] == '(') st.push(i);
else{
ans[st.top()] = i;
ans[i] = st.top();
st.pop();
}
}
for(int i = 0; i < N; i++){
cout << ans[i] + 1 << endl;
}
}
femto