結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
![]() |
提出日時 | 2017-11-10 22:42:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 272 ms / 5,000 ms |
コード長 | 403 bytes |
コンパイル時間 | 1,523 ms |
コンパイル使用メモリ | 163,680 KB |
実行使用メモリ | 5,760 KB |
最終ジャッジ日時 | 2024-11-24 12:57:40 |
合計ジャッジ時間 | 2,637 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <bits/stdc++.h>#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)using namespace std;typedef long long ll;ll N;string S;int main(void) {cin >> N >> S;vector<ll> ans(N);stack<ll> stk;REP(i, 0, N) {if(S[i] == '(') stk.push(i);else {ans[i] = stk.top();ans[ans[i]] = i;stk.pop();}}REP(i, 0, N) cout << ans[i] + 1 << endl;}