結果
| 問題 | No.92 逃走経路 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-02 23:51:35 |
| 言語 | Ruby (4.0.2) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 524 bytes |
| 記録 | |
| コンパイル時間 | 228 ms |
| コンパイル使用メモリ | 8,960 KB |
| 実行使用メモリ | 22,272 KB |
| 最終ジャッジ日時 | 2026-05-16 15:58:15 |
| 合計ジャッジ時間 | 13,024 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 17 |
コンパイルメッセージ
Syntax OK
ソースコード
N, M, K = gets.split.map &:to_i
edges = []
M.times.map{
a, b, c = gets.split.map &:to_i
edges << [a, b, c] << [b, a, c]
}
tollages = gets.split.map &:to_i
starts = []
edges.each{|a,b,c|
starts << a if c == tollages[0]
}
starts.uniq!
checked = [false] * -~N
dfs = ->pos, i{
if i == K
checked[pos] = true
return
end
edges.each{|a,b,c|
next if c != tollages[i]
next if a != pos
dfs[b, i+1]
}
}
starts.each{|start|
dfs[start, 1]
}
p checked.count(true)
puts (1..N).select{|i|checked[i]}*" "