結果
問題 | No.592 括弧の対応 (2) |
ユーザー | ei1333333 |
提出日時 | 2017-11-10 22:22:06 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 238 ms / 5,000 ms |
コード長 | 373 bytes |
コンパイル時間 | 1,856 ms |
コンパイル使用メモリ | 201,800 KB |
実行使用メモリ | 4,588 KB |
最終ジャッジ日時 | 2023-08-16 02:35:53 |
合計ジャッジ時間 | 3,196 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 236 ms
4,376 KB |
testcase_02 | AC | 235 ms
4,588 KB |
testcase_03 | AC | 238 ms
4,504 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N; string S; cin >> N; cin >> S; stack< int > st; int ans[200000]; for(int i = 0; i < N; i++) { if(S[i] == '(') st.push(i); else { int p = st.top(); st.pop(); ans[i] = p; ans[p] = i; } } for(int i = 0; i < N; i++) { cout << ans[i] + 1 << endl; } }