結果
問題 | No.592 括弧の対応 (2) |
ユーザー | tnakao0123 |
提出日時 | 2017-11-13 09:24:15 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 24 ms / 5,000 ms |
コード長 | 855 bytes |
コンパイル時間 | 759 ms |
コンパイル使用メモリ | 86,340 KB |
実行使用メモリ | 4,744 KB |
最終ジャッジ日時 | 2023-08-16 11:56:44 |
合計ジャッジ時間 | 1,425 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 24 ms
4,572 KB |
testcase_02 | AC | 24 ms
4,744 KB |
testcase_03 | AC | 23 ms
4,384 KB |
ソースコード
/* -*- coding: utf-8 -*- * * 592.cc: No.592 括弧の対応 (2) - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ typedef stack<int> si; /* global variables */ int ps[MAX_N]; /* subroutines */ /* main */ int main() { int n; string s; cin >> n >> s; si st; for (int i = 0; i < n; i++) { if (s[i] == '(') st.push(i); else { int j = st.top(); st.pop(); ps[i] = j; ps[j] = i; } } for (int i = 0; i < n; i++) printf("%d\n", ps[i] + 1); return 0; }