結果
問題 | No.2179 Planet Traveler |
ユーザー | kakel-san |
提出日時 | 2023-09-05 21:04:10 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 114 ms / 3,000 ms |
コード長 | 2,422 bytes |
コンパイル時間 | 2,141 ms |
コンパイル使用メモリ | 113,068 KB |
実行使用メモリ | 35,972 KB |
最終ジャッジ日時 | 2024-06-23 16:26:57 |
合計ジャッジ時間 | 4,040 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
27,472 KB |
testcase_01 | AC | 31 ms
25,440 KB |
testcase_02 | AC | 31 ms
25,344 KB |
testcase_03 | AC | 32 ms
25,440 KB |
testcase_04 | AC | 32 ms
25,316 KB |
testcase_05 | AC | 32 ms
25,436 KB |
testcase_06 | AC | 32 ms
27,224 KB |
testcase_07 | AC | 32 ms
25,572 KB |
testcase_08 | AC | 33 ms
27,220 KB |
testcase_09 | AC | 32 ms
23,344 KB |
testcase_10 | AC | 32 ms
25,312 KB |
testcase_11 | AC | 72 ms
35,464 KB |
testcase_12 | AC | 79 ms
33,420 KB |
testcase_13 | AC | 75 ms
35,588 KB |
testcase_14 | AC | 94 ms
33,412 KB |
testcase_15 | AC | 108 ms
33,412 KB |
testcase_16 | AC | 102 ms
35,340 KB |
testcase_17 | AC | 111 ms
35,592 KB |
testcase_18 | AC | 111 ms
33,540 KB |
testcase_19 | AC | 101 ms
35,584 KB |
testcase_20 | AC | 39 ms
23,476 KB |
testcase_21 | AC | 114 ms
33,552 KB |
testcase_22 | AC | 70 ms
27,648 KB |
testcase_23 | AC | 64 ms
25,592 KB |
testcase_24 | AC | 97 ms
35,972 KB |
testcase_25 | AC | 69 ms
27,508 KB |
testcase_26 | AC | 93 ms
35,724 KB |
testcase_27 | AC | 41 ms
25,136 KB |
testcase_28 | AC | 58 ms
27,512 KB |
testcase_29 | AC | 99 ms
34,056 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; 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(); public static void Main() { Solve(); } static void Solve() { var n = NN; var map = NArr(n); var dp = new long[n][]; for (var i = 0; i < n; ++i) dp[i] = new long[n]; var tree = new List<(int to, long len)>[n]; for (var i = 0; i < tree.Length; ++i) tree[i] = new List<(int to, long len)>(); for (var i = 0; i < n; ++i) for (var j = i + 1; j < n; ++j) { if (map[i][2] == map[j][2]) { var len = (long)(map[i][0] - map[j][0]) * (map[i][0] - map[j][0]) + (long)(map[i][1] - map[j][1]) * (map[i][1] - map[j][1]); dp[i][j] = len; dp[j][i] = len; } else { var a = (long)map[i][0] * map[i][0] + (long)map[i][1] * map[i][1]; var b = (long)map[j][0] * map[j][0] + (long)map[j][1] * map[j][1]; var len = a + b - SqrtFloor(4 * a * b); dp[i][j] = len; dp[j][i] = len; } } var ok = 3200000001L; var ng = -1L; while (ok - ng > 1) { var mid = (ok + ng) / 2; var q = new Queue<int>(); q.Enqueue(0); var visited = new bool[n]; visited[0] = true; while (q.Count > 0) { var cur = q.Dequeue(); for (var i = 0; i < n; ++i) { if (visited[i]) continue; if (dp[cur][i] > mid) continue; visited[i] = true; q.Enqueue(i); } } if (visited[n - 1]) ok = mid; else ng = mid; } WriteLine(ok); } static long SqrtFloor(long a) { var sq = Math.Sqrt(a); for (var i = Math.Max(0, (long)sq - 10); i < sq + 10; ++i) { if (i * i <= a && a < (i + 1) * (i + 1)) return i; } return 0; } }