結果

問題 No.592 括弧の対応 (2)
ユーザー CleyLCleyL
提出日時 2020-02-18 03:46:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 268 ms / 5,000 ms
コード長 479 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 75,840 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 04:03:24
合計ジャッジ時間 1,952 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 268 ms
6,940 KB
testcase_02 AC 265 ms
6,940 KB
testcase_03 AC 261 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <stack>
using namespace std;
int main(){
    int n;cin>>n;
    string s;cin>>s;
    stack<int> nya;
    vector<int> ans(n);
    for(int i = 0; n > i; i++){
        ans[i] = i;
    }
    for(int i = 0; n > i; i++){
        if(s[i] == '('){
            nya.push(i);
        }else{
            swap(ans[nya.top()],ans[i]);
            nya.pop();
        }
    }
    for(int i = 0; n > i; i++){
        cout << ans[i]+1 << endl;
    }
}
0