結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
|
提出日時 | 2017-11-10 22:28:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 250 ms / 5,000 ms |
コード長 | 785 bytes |
コンパイル時間 | 683 ms |
コンパイル使用メモリ | 87,360 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-24 12:34:24 |
合計ジャッジ時間 | 1,923 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <iostream>#include <string>#include <vector>#include <set>#include <map>#include <stack>#include <queue>#include <algorithm>#include <cstdio>#include <cstdlib>#include <cmath>using namespace std;using ll = long long;using P = pair<int, int>;const int MAX = 2e5;const int INF = 1e9;const int MOD = 1e9 + 7;// 4近傍、8近傍int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};int c[MAX];int main() {// 入力int N;cin >> N;string s;cin >> s;stack<int> st;for (int i = 0; i < N; i++) {if (s[i] == '(') {st.push(i);} else {c[i] = st.top();c[c[i]] = i;st.pop();}}// 解答for (int i = 0; i < N; i++) {cout << c[i] + 1 << endl;}return 0;}