結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
![]() |
提出日時 | 2017-11-10 23:12:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 5,000 ms |
コード長 | 362 bytes |
コンパイル時間 | 795 ms |
コンパイル使用メモリ | 71,272 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 15:07:40 |
合計ジャッジ時間 | 1,493 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <stack>#include <string>#include <iostream>using namespace std;int n, ans[200009]; string s;int main() {cin >> n >> s;stack<int> st;for (int i = 0; i < n; i++) {if (s[i] == '(') st.push(i);else {int v = st.top();st.pop();ans[i] = v;ans[v] = i;}}for (int i = 0; i < n; i++) cout << ans[i] + 1 << '\n';return 0;}