結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2015-01-11 06:26:05 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 99 ms / 5,000 ms |
| コード長 | 349 bytes |
| コンパイル時間 | 109 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,800 KB |
| 最終ジャッジ日時 | 2024-07-20 06:56:20 |
| 合計ジャッジ時間 | 2,686 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - n Syntax OK
ソースコード
class A
def initialize
n, k = gets.chomp.split(' ').map(&:to_i)
s = gets.chomp.chars
answer = []
stack = []
s.each.with_index(1) do |ch, index|
if ch == '('
stack << index
else
i = stack.pop
answer[i] = index
answer[index] = i
end
end
puts answer[k]
end
end
A.new
siman