結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
![]() |
提出日時 | 2017-11-10 22:37:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 264 ms / 5,000 ms |
コード長 | 587 bytes |
コンパイル時間 | 1,736 ms |
コンパイル使用メモリ | 171,980 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 12:51:30 |
合計ジャッジ時間 | 3,118 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i, j) for(int i=0; i < (int)(j); i++)class Solver {public:bool solve() {int N; cin >> N;string S; cin >> S;stack<int> stk;vector<int> res(N);rep(i, N) {if(S[i] == '(') stk.push(i);else {int p = stk.top(); stk.pop();res[p] = i + 1;res[i] = p + 1;}}rep(i, N) cout << res[i] << endl;return 0;}};int main() {Solver s;s.solve();return 0;}