結果
問題 | No.96 圏外です。 |
ユーザー | kakel-san |
提出日時 | 2023-10-21 20:37:12 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 978 ms / 5,000 ms |
コード長 | 4,724 bytes |
コンパイル時間 | 7,212 ms |
コンパイル使用メモリ | 167,416 KB |
実行使用メモリ | 220,612 KB |
最終ジャッジ日時 | 2024-09-21 22:03:35 |
合計ジャッジ時間 | 21,022 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 69 ms
31,104 KB |
testcase_01 | AC | 56 ms
30,848 KB |
testcase_02 | AC | 67 ms
31,488 KB |
testcase_03 | AC | 52 ms
30,592 KB |
testcase_04 | AC | 99 ms
34,560 KB |
testcase_05 | AC | 105 ms
35,200 KB |
testcase_06 | AC | 125 ms
36,352 KB |
testcase_07 | AC | 132 ms
37,632 KB |
testcase_08 | AC | 161 ms
38,784 KB |
testcase_09 | AC | 179 ms
41,696 KB |
testcase_10 | AC | 229 ms
45,824 KB |
testcase_11 | AC | 292 ms
47,488 KB |
testcase_12 | AC | 325 ms
47,488 KB |
testcase_13 | AC | 460 ms
52,864 KB |
testcase_14 | AC | 510 ms
54,040 KB |
testcase_15 | AC | 559 ms
59,652 KB |
testcase_16 | AC | 674 ms
63,552 KB |
testcase_17 | AC | 805 ms
69,700 KB |
testcase_18 | AC | 978 ms
70,864 KB |
testcase_19 | AC | 891 ms
70,784 KB |
testcase_20 | AC | 874 ms
74,556 KB |
testcase_21 | AC | 649 ms
71,380 KB |
testcase_22 | AC | 808 ms
74,940 KB |
testcase_23 | AC | 812 ms
75,476 KB |
testcase_24 | AC | 64 ms
30,848 KB |
testcase_25 | AC | 576 ms
59,160 KB |
testcase_26 | AC | 708 ms
66,132 KB |
testcase_27 | AC | 592 ms
220,612 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (85 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) 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;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);if (n == 0){WriteLine(1);return;}Array.Sort(map, (l, r) => l[0].CompareTo(r[0]));var dic = new Dictionary<int, int>();for (var i = 0; i < n; ++i){dic[Key(map[i][0], map[i][1])] = i;}var uf = new UnionFindTree(n);for (var i = 0; i < n; ++i){for (var dx = 0; dx <= 10; ++dx) for (var dy = 0; dy <= 10; ++dy){if (dx * dx + dy * dy > 100) break;var key = Key(map[i][0] + dx, map[i][1] + dy);if (dic.ContainsKey(key)) uf.Unite(i, dic[key]);key = Key(map[i][0] + dx, map[i][1] - dy);if (dic.ContainsKey(key)) uf.Unite(i, dic[key]);}}var lists = new List<int[]>[n];for (var i = 0; i < lists.Length; ++i) lists[i] = new List<int[]>();for (var i = 0; i < n; ++i) lists[uf.GetRoot(i)].Add(map[i]);var ans = 0;for (var i = 0; i < n; ++i){if (lists[i].Count > 1){var ch = MakeConvexHull(lists[i]);for (var j = 0; j < ch.Count; ++j) for (var k = j + 1; k < ch.Count; ++k){var p = lists[i][ch[j]];var q = lists[i][ch[k]];ans = Math.Max(ans, (p[0] - q[0]) * (p[0] - q[0]) + (p[1] - q[1]) * (p[1] - q[1]));}}}WriteLine(Math.Sqrt(ans) + 2);}static int Key(int x, int y){return x * 100000 + y;}class UnionFindTree{int[] roots;public UnionFindTree(int size){roots = new int[size];for (var i = 0; i < size; ++i) roots[i] = -1;}public int GetRoot(int a){if (roots[a] < 0) return a;return roots[a] = GetRoot(roots[a]);}public bool IsSameTree(int a, int b){return GetRoot(a) == GetRoot(b);}public bool Unite(int a, int b){var x = GetRoot(a);var y = GetRoot(b);if (x == y) return false;if (-roots[x] < -roots[y]) { var tmp = x; x = y; y = tmp; }roots[x] += roots[y];roots[y] = x;return true;}public int GetSize(int a){return -roots[GetRoot(a)];}}static List<int> MakeConvexHull(List<int[]> _map){var map = _map.Select((xy, id) => (xy, id)).ToList();map.Sort((l, r) =>{var d = l.xy[0].CompareTo(r.xy[0]);if (d != 0) return d;return l.xy[1].CompareTo(r.xy[1]);});var dn = new List<(int[] xy, int id)>();dn.Add(map[0]);for (var i = 1; i < map.Count; ++i){while (dn.Count > 1){var p2 = dn[dn.Count - 2].xy;var p1 = dn[dn.Count - 1].xy;if (OuterProduct(p1[0] - p2[0], p1[1] - p2[1], map[i].xy[0] - p1[0], map[i].xy[1] - p1[1]) <= 0){dn.RemoveAt(dn.Count - 1);}else break;}dn.Add(map[i]);}var up = new List<(int[] xy, int id)>();up.Add(map[map.Count - 1]);for (var i = map.Count - 2; i >= 0; --i){while (up.Count > 1){var p2 = up[up.Count - 2].xy;var p1 = up[up.Count - 1].xy;if (OuterProduct(p1[0] - p2[0], p1[1] - p2[1], map[i].xy[0] - p1[0], map[i].xy[1] - p1[1]) <= 0){up.RemoveAt(up.Count - 1);}else break;}up.Add(map[i]);}dn.AddRange(up.Skip(1).Take(up.Count - 2));return dn.Select(li => li.id).ToList();}static long OuterProduct(int ax, int ay, int bx, int by){return (long)ax * by - (long)ay * bx;}}