結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-26 01:44:19 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 727 bytes |
| コンパイル時間 | 60 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 18,816 KB |
| 最終ジャッジ日時 | 2024-10-02 00:50:54 |
| 合計ジャッジ時間 | 2,843 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 7 WA * 11 |
コンパイルメッセージ
Main.rb:16: 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|
idx = list[s][0].index(x)
if idx
ans.push(list[s][1][idx])
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], d, list).map{|i|i + 1}.sort
p ans.size
puts ans.join(' ')