結果
| 問題 | No.92 逃走経路 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-26 01:53:45 |
| 言語 | Ruby (4.0.2) |
| 結果 |
AC
|
| 実行時間 | 367 ms / 5,000 ms |
| コード長 | 766 bytes |
| 記録 | |
| コンパイル時間 | 166 ms |
| コンパイル使用メモリ | 9,088 KB |
| 実行使用メモリ | 45,056 KB |
| 最終ジャッジ日時 | 2026-06-01 02:28:48 |
| 合計ジャッジ時間 | 5,051 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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(' ')