結果

問題 No.592 括弧の対応 (2)
ユーザー kcz146kcz146
提出日時 2017-11-27 19:23:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 414 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 25,352 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 07:38:24
合計ジャッジ時間 931 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 22 ms
4,376 KB
testcase_02 AC 21 ms
4,380 KB
testcase_03 AC 19 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>

char s[300000];
int prevd[300000];
int map[300000];

int main(void) {
    int n;
    scanf("%d",&n);
    scanf("%s",s);

    int d=0;
    for(int i=0; i<n; i++)
        if(s[i]=='(') {
            prevd[d] = i;
            d++;
        } else {
            d--;
            map[i] = prevd[d];
            map[prevd[d]] = i;
        }
    for(int i=0; i<n; i++)
        printf("%d\n", map[i]+1);
}
0