結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-21 17:52:44 |
| 言語 | Ruby (4.0.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 314 bytes |
| 記録 | |
| コンパイル時間 | 219 ms |
| コンパイル使用メモリ | 9,088 KB |
| 実行使用メモリ | 16,000 KB |
| 最終ジャッジ日時 | 2026-03-10 23:58:53 |
| 合計ジャッジ時間 | 2,218 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 15 |
コンパイルメッセージ
Syntax OK
ソースコード
_, K = gets.split.map(&:to_i)
S = gets.chomp
start_paren_index = 0
paren_table = {}
S.chars.each.with_index(1) do |paren, i|
if paren == '('
start_paren_index += 1
else
paren_table[start_paren_index] = i
paren_table[i] = start_paren_index
start_paren_index -= 1
end
end
puts paren_table[K]