結果

問題 No.592 括弧の対応 (2)
ユーザー squidsquid
提出日時 2017-11-10 23:36:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 272 ms / 5,000 ms
コード長 456 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 62,372 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 14:42:37
合計ジャッジ時間 2,046 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 272 ms
5,376 KB
testcase_02 AC 271 ms
5,376 KB
testcase_03 AC 270 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int n;
string s;
int h[200001];
stack<int> kakko;

int main(){
    cin>>n>>s;
    for(int i=0; i<n; i++){
        int a=i+1;
        int b;
        if(s[i]=='('){
            kakko.push(a);
        }
        else{
            b=kakko.top();
            kakko.pop();
            h[a]=b;
            h[b]=a;
        }
    }
    for(int i=1; i<=n; i++){
        cout<<h[i]<<endl;
    }
    return 0;
}
0