結果
問題 | No.592 括弧の対応 (2) |
ユーザー | kurenai3110 |
提出日時 | 2017-11-10 22:28:13 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 273 ms / 5,000 ms |
コード長 | 408 bytes |
コンパイル時間 | 531 ms |
コンパイル使用メモリ | 68,036 KB |
実行使用メモリ | 4,480 KB |
最終ジャッジ日時 | 2023-08-16 03:01:49 |
合計ジャッジ時間 | 1,980 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 273 ms
4,380 KB |
testcase_02 | AC | 265 ms
4,480 KB |
testcase_03 | AC | 269 ms
4,376 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <stack> using namespace std; int main() { int N; cin >> N; string S; cin >> S; vector<int>A(N); stack<int>st; for (int i = 0; i < S.size(); i++) { if (S[i]==')') { int p = st.top();st.pop(); A[p] = i;A[i] = p; } else st.push(i); } for (int i = 0; i < N; i++)cout << A[i]+1 << endl; return 0; }