結果

問題 No.592 括弧の対応 (2)
ユーザー giusto_program
提出日時 2017-11-11 10:10:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 243 ms / 5,000 ms
コード長 406 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 62,836 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-24 18:51:59
合計ジャッジ時間 1,806 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stack>
using namespace std;

int n, cr[200005];
char c[200005];
stack<int> s;

int main() {
    cin >> n >> c;

    for (int i = 0; i < n; i++) {
        if (c[i] == '(') {
            s.push(i);
        }
        else {
            cr[i] = s.top();
            cr[s.top()] = i;

            s.pop();
        }
    }

    for (int i = 0; i < n; i++) cout << cr[i] + 1 << endl;
}
0