結果

問題 No.592 括弧の対応 (2)
ユーザー CleyLCleyL
提出日時 2020-02-18 03:45:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 522 bytes
コンパイル時間 710 ms
コンパイル使用メモリ 76,348 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 04:03:22
合計ジャッジ時間 1,258 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
        if(i+1 != n)cout << " ";
    }
    cout << endl;
}
0