結果

問題 No.92 逃走経路
コンテスト
ユーザー siman
提出日時 2015-04-02 21:10:03
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 261 ms / 5,000 ms
コード長 549 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 344 ms
コンパイル使用メモリ 8,960 KB
実行使用メモリ 39,168 KB
最終ジャッジ日時 2026-06-01 11:50:53
合計ジャッジ時間 3,615 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - k
Syntax OK

ソースコード

diff #
raw source code

class Yukicoder
  def initialize
    n, m, k = gets.chomp.split(' ').map(&:to_i)
    paths = Hash.new{|h,k| h[k] = Hash.new{|h,k| h[k] = []}}

    m.times do
      a, b, c = gets.chomp.split(' ').map(&:to_i)
      paths[a][c] << b
      paths[b][c] << a
    end

    d = gets.chomp.split(' ').map(&:to_i)

    current = [*(1..n)]

    d.each do |cost|
      temp = []

      current.each do |i|
        temp |= paths[i][cost]
      end

      current = temp.dup
    end

    puts current.size
    puts current.sort.join(' ')
  end
end

Yukicoder.new
0