結果

問題 No.22 括弧の対応
ユーザー teioteio
提出日時 2020-07-29 14:01:11
言語 Perl
(5.38.2)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 352 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 5,244 KB
最終ジャッジ日時 2023-09-27 13:48:35
合計ジャッジ時間 1,157 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,500 KB
testcase_01 AC 3 ms
4,680 KB
testcase_02 AC 3 ms
4,668 KB
testcase_03 AC 6 ms
5,244 KB
testcase_04 AC 4 ms
4,980 KB
testcase_05 AC 4 ms
4,736 KB
testcase_06 AC 6 ms
5,080 KB
testcase_07 AC 4 ms
4,984 KB
testcase_08 AC 3 ms
5,092 KB
testcase_09 AC 6 ms
4,804 KB
testcase_10 AC 4 ms
5,192 KB
testcase_11 AC 4 ms
4,996 KB
testcase_12 AC 5 ms
4,876 KB
testcase_13 AC 8 ms
4,956 KB
testcase_14 AC 3 ms
4,812 KB
testcase_15 AC 6 ms
5,032 KB
testcase_16 AC 7 ms
5,156 KB
testcase_17 AC 2 ms
4,620 KB
testcase_18 AC 3 ms
4,736 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

# use strict;
# use warnings;

chomp(my $x = <>);
my ($N, $K) = split(/ /, $x);
chomp(my $S = <>);
my @ns = 1 .. $N;
$_ = $S;
while (s/\(\)//) {
    if ($ns[$-[0]] == $K) {
        print($ns[$-[0] + 1], "\n");
        exit;
    }
    if ($ns[$-[0] + 1] == $K) {
        print($ns[$-[0]], "\n");
        exit;
    }
    splice(@ns, $-[0], 2);
}
exit 1;
0