結果
問題 |
No.1065 電柱 / Pole (Easy)
|
ユーザー |
|
提出日時 | 2025-10-17 21:25:59 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 684 ms / 2,000 ms |
コード長 | 2,216 bytes |
コンパイル時間 | 8,095 ms |
コンパイル使用メモリ | 170,576 KB |
実行使用メモリ | 190,412 KB |
最終ジャッジ日時 | 2025-10-17 21:26:28 |
合計ジャッジ時間 | 26,066 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 46 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (111 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; using System.Globalization; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); static long[] LList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => long.Parse(ReadLine())).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, m) = (c[0], c[1]); c = NMi; var (x, y) = (c[0], c[1]); var map = NArr(n); var edges = NMap(m); var tree = new List<(int to, double len)>[n]; for (var i = 0; i < n; ++i) tree[i] = new List<(int to, double len)>(); foreach (var edge in edges) { var len = Length(map[edge[0]][0], map[edge[0]][1], map[edge[1]][0], map[edge[1]][1]); tree[edge[0]].Add((edge[1], len)); tree[edge[1]].Add((edge[0], len)); } var llist = Enumerable.Repeat(double.MaxValue / 2, n).ToArray(); llist[x] = 0; var q = new PriorityQueue<(int pos, double len), double>(); q.Enqueue((x, 0), 0); while (q.Count > 0) { var cur = q.Dequeue(); if (llist[cur.pos] != cur.len) continue; foreach (var next in tree[cur.pos]) { if (llist[next.to] <= cur.len + next.len) continue; llist[next.to] = cur.len + next.len; q.Enqueue((next.to, llist[next.to]), llist[next.to]); } } WriteLine(llist[y]); } static double Length(int ax, int ay, int bx, int by) { return Math.Sqrt(((long)ax - bx) * (ax - bx) + ((long)ay - by) * (ay - by)); } }