結果
問題 | No.22 括弧の対応 |
ユーザー | papinianus |
提出日時 | 2016-06-02 16:46:04 |
言語 | PHP (8.3.4) |
結果 |
AC
|
実行時間 | 17 ms / 5,000 ms |
コード長 | 402 bytes |
コンパイル時間 | 622 ms |
コンパイル使用メモリ | 18,520 KB |
実行使用メモリ | 20,888 KB |
最終ジャッジ日時 | 2023-09-27 13:06:21 |
合計ジャッジ時間 | 1,546 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 13 ms
18,796 KB |
testcase_01 | AC | 14 ms
18,828 KB |
testcase_02 | AC | 14 ms
18,788 KB |
testcase_03 | AC | 15 ms
20,788 KB |
testcase_04 | AC | 14 ms
18,748 KB |
testcase_05 | AC | 14 ms
18,816 KB |
testcase_06 | AC | 14 ms
18,568 KB |
testcase_07 | AC | 14 ms
18,816 KB |
testcase_08 | AC | 17 ms
18,812 KB |
testcase_09 | AC | 15 ms
18,824 KB |
testcase_10 | AC | 14 ms
18,572 KB |
testcase_11 | AC | 13 ms
18,780 KB |
testcase_12 | AC | 14 ms
18,764 KB |
testcase_13 | AC | 14 ms
18,820 KB |
testcase_14 | AC | 14 ms
18,760 KB |
testcase_15 | AC | 15 ms
20,740 KB |
testcase_16 | AC | 15 ms
20,888 KB |
testcase_17 | AC | 14 ms
18,840 KB |
testcase_18 | AC | 13 ms
18,812 KB |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php list($len, $target) = explode(' ', trim(fgets(STDIN))); $str = str_split(trim(fgets(STDIN))); $lefts = []; $structOfStr = []; foreach($str as $i => $char) { if($char == '(') { array_push($lefts, $i); } else { // ')' $prevLeft = array_pop($lefts); $structOfStr[$i] = $prevLeft; $structOfStr[$prevLeft] = $i; } } echo ($structOfStr[$target-1]+1).PHP_EOL;