結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー universatouniversato
提出日時 2020-05-29 21:59:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,177 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 41 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 47,872 KB
最終ジャッジ日時 2024-04-24 10:54:56
合計ジャッジ時間 25,820 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
12,160 KB
testcase_01 AC 76 ms
12,288 KB
testcase_02 AC 491 ms
30,336 KB
testcase_03 AC 828 ms
33,152 KB
testcase_04 AC 1,055 ms
33,408 KB
testcase_05 AC 685 ms
33,280 KB
testcase_06 AC 679 ms
33,152 KB
testcase_07 AC 267 ms
20,480 KB
testcase_08 AC 815 ms
44,672 KB
testcase_09 AC 140 ms
14,208 KB
testcase_10 AC 412 ms
26,240 KB
testcase_11 AC 309 ms
21,888 KB
testcase_12 AC 248 ms
14,592 KB
testcase_13 AC 876 ms
27,648 KB
testcase_14 AC 706 ms
31,488 KB
testcase_15 AC 956 ms
35,456 KB
testcase_16 AC 612 ms
20,352 KB
testcase_17 AC 1,177 ms
32,640 KB
testcase_18 AC 429 ms
18,176 KB
testcase_19 AC 1,058 ms
36,480 KB
testcase_20 AC 307 ms
18,688 KB
testcase_21 AC 567 ms
18,304 KB
testcase_22 AC 783 ms
33,280 KB
testcase_23 AC 85 ms
12,416 KB
testcase_24 AC 89 ms
12,416 KB
testcase_25 AC 231 ms
13,568 KB
testcase_26 AC 604 ms
24,448 KB
testcase_27 AC 529 ms
23,680 KB
testcase_28 AC 772 ms
30,976 KB
testcase_29 AC 193 ms
13,568 KB
testcase_30 AC 828 ms
33,152 KB
testcase_31 AC 511 ms
27,264 KB
testcase_32 AC 348 ms
23,424 KB
testcase_33 AC 679 ms
33,024 KB
testcase_34 AC 389 ms
18,944 KB
testcase_35 AC 787 ms
34,048 KB
testcase_36 AC 82 ms
12,544 KB
testcase_37 AC 87 ms
12,416 KB
testcase_38 AC 84 ms
12,544 KB
testcase_39 AC 89 ms
12,416 KB
testcase_40 AC 82 ms
12,288 KB
testcase_41 AC 960 ms
47,872 KB
testcase_42 AC 321 ms
21,632 KB
testcase_43 AC 515 ms
30,848 KB
testcase_44 AC 225 ms
17,792 KB
testcase_45 AC 489 ms
30,208 KB
testcase_46 AC 78 ms
12,160 KB
testcase_47 AC 77 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, m = gets.to_s.split.map{|t| t.to_i }
x, y = gets.to_s.split.map{|t| t.to_i - 1 }

xys = Array.new(n){ gets.to_s.split.map{|t| t.to_i } }

g = Array.new(n){ [] }
m.times do
  s, t = gets.to_s.split.map{|t| t.to_i - 1 }
  g[s] << t
  g[t] << s
end

inf = Float::INFINITY
d = [inf] * n
d[x] = 0
q = [x]

while ( v = q.shift )
  
  d_v = d[v] 
  g[v].each do |u|
    t = Math.hypot( xys[u][0] - xys[v][0], xys[u][1] - xys[v][1] )
    if d[u] > d_v + t
      d[u] = d_v + t
      q.push u
    end
  end
end

puts d[y]
0