結果
問題 |
No.592 括弧の対応 (2)
|
ユーザー |
![]() |
提出日時 | 2017-11-11 12:52:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 262 ms / 5,000 ms |
コード長 | 339 bytes |
コンパイル時間 | 1,761 ms |
コンパイル使用メモリ | 170,940 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 18:59:29 |
合計ジャッジ時間 | 3,186 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int ans[n]; stack<int> st; for (int i = 0; i < n; i++) { if (s[i] == '(') { st.emplace(i); } else { int a = st.top(); st.pop(); ans[i] = a; ans[a] = i; } } for (auto &i : ans) { cout << i + 1 << endl; } return 0; }