結果
問題 | No.92 逃走経路 |
ユーザー |
|
提出日時 | 2016-03-26 01:53:45 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 534 ms / 5,000 ms |
コード長 | 766 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 42,496 KB |
最終ジャッジ日時 | 2024-12-26 06:06:17 |
合計ジャッジ時間 | 5,985 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
コンパイルメッセージ
Main.rb:17: warning: assigned but unused variable - k Syntax OK
ソースコード
def sol c, d, list if d.empty? return c end x = d.shift ans = [] c.each{|s| list[s][0].each_with_index{|v,i| if v == x ans.push(list[s][1][i]) end } } return sol(ans.uniq, d, list) end n,m,k = gets.split.map(&:to_i) fee = Hash.new([]) list = Array.new(n) n.times{|i| list[i] = Array.new(2) list[i][0] = [] list[i][1] = [] } m.times{ a,b,c = gets.split.map(&:to_i) fee[c] = fee[c] + [a - 1,b - 1] list[a - 1][0].push(c) list[a - 1][1].push(b - 1) list[b - 1][0].push(c) list[b - 1][1].push(a - 1) } d = gets.split.map(&:to_i) x = d.shift ans = sol(fee[x].uniq, d, list).map{|i|i + 1}.sort p ans.size puts ans.join(' ')