結果
問題 | No.2376 障害物競プロ |
ユーザー | kakel-san |
提出日時 | 2023-07-13 20:35:52 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 1,584 ms / 4,000 ms |
コード長 | 3,279 bytes |
コンパイル時間 | 2,915 ms |
コンパイル使用メモリ | 109,568 KB |
実行使用メモリ | 50,560 KB |
最終ジャッジ日時 | 2024-09-15 06:41:55 |
合計ジャッジ時間 | 73,676 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
20,224 KB |
testcase_01 | AC | 35 ms
20,480 KB |
testcase_02 | AC | 35 ms
20,224 KB |
testcase_03 | AC | 35 ms
20,352 KB |
testcase_04 | AC | 644 ms
41,856 KB |
testcase_05 | AC | 868 ms
49,024 KB |
testcase_06 | AC | 385 ms
33,280 KB |
testcase_07 | AC | 1,143 ms
50,560 KB |
testcase_08 | AC | 1,159 ms
50,560 KB |
testcase_09 | AC | 1,136 ms
50,432 KB |
testcase_10 | AC | 1,171 ms
50,304 KB |
testcase_11 | AC | 1,013 ms
47,616 KB |
testcase_12 | AC | 942 ms
45,568 KB |
testcase_13 | AC | 1,116 ms
50,432 KB |
testcase_14 | AC | 1,109 ms
49,920 KB |
testcase_15 | AC | 1,047 ms
49,024 KB |
testcase_16 | AC | 1,115 ms
50,176 KB |
testcase_17 | AC | 954 ms
46,080 KB |
testcase_18 | AC | 911 ms
46,720 KB |
testcase_19 | AC | 1,539 ms
47,104 KB |
testcase_20 | AC | 1,584 ms
48,256 KB |
testcase_21 | AC | 1,563 ms
48,256 KB |
testcase_22 | AC | 888 ms
46,336 KB |
testcase_23 | AC | 624 ms
37,248 KB |
testcase_24 | AC | 642 ms
43,136 KB |
testcase_25 | AC | 334 ms
32,512 KB |
testcase_26 | AC | 734 ms
45,184 KB |
testcase_27 | AC | 638 ms
41,728 KB |
testcase_28 | AC | 401 ms
32,512 KB |
testcase_29 | AC | 336 ms
32,640 KB |
testcase_30 | AC | 401 ms
29,696 KB |
testcase_31 | AC | 396 ms
33,792 KB |
testcase_32 | AC | 81 ms
24,304 KB |
testcase_33 | AC | 189 ms
26,112 KB |
testcase_34 | AC | 230 ms
28,416 KB |
testcase_35 | AC | 156 ms
27,520 KB |
testcase_36 | AC | 688 ms
37,760 KB |
testcase_37 | AC | 818 ms
45,952 KB |
testcase_38 | AC | 320 ms
31,616 KB |
testcase_39 | AC | 883 ms
42,624 KB |
testcase_40 | AC | 333 ms
26,112 KB |
testcase_41 | AC | 301 ms
31,616 KB |
testcase_42 | AC | 1,429 ms
50,560 KB |
testcase_43 | AC | 1,563 ms
50,560 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 c = NList; var (n, m) = (c[0], c[1]); var map = NArr(n); var query = NArr(m); var points = new int[n * 2][]; for (var i = 0; i < n; ++i) { points[i * 2] = new int[] { map[i][0], map[i][1] }; points[i * 2 + 1] = new int[] { map[i][2], map[i][3] }; } var INF = double.MaxValue / 2; var dp = new double[n * 2][]; for (var i = 0; i < dp.Length; ++i) dp[i] = Enumerable.Repeat(INF, n * 2).ToArray(); for (var i = 0; i < n; ++i) for (var j = 0; j < n; ++j) { void calc(int a, int b) { var flg = true; for (var k = 0; k < n; ++k) { if (a / 2 == k || b / 2 == k) continue; if (Cross(points[a], points[b], points[k * 2], points[k * 2 + 1])) { flg = false; break; } } if (flg) { dp[a][b] = Length(points[a], points[b]); dp[b][a] = dp[a][b]; } } calc(i * 2, j * 2); calc(i * 2, j * 2 + 1); calc(i * 2 + 1, j * 2); calc(i * 2 + 1, j * 2 + 1); } for (var k = 0; k < dp.Length; ++k) for (var i = 0; i < dp.Length; ++i) for (var j = 0; j < dp.Length; ++j) { dp[i][j] = Math.Min(dp[i][j], dp[i][k] + dp[k][j]); } var ans = new double[m]; for (var i = 0; i < m; ++i) { ans[i] = dp[query[i][0] * 2 + query[i][1] - 3][query[i][2] * 2 + query[i][3] - 3]; } WriteLine(string.Join("\n", ans)); } static bool Cross(int[] a, int[] b, int[] c, int[] d) { var sa = AreaSign(c, d, a); var sb = AreaSign(c, d, b); var sc = AreaSign(a, b, c); var sd = AreaSign(a, b, d); if (sa == 0 && sb == 0 && sc == 0 && sd == 0) { return false; } return sa != sb && sc != sd; } static int AreaSign(int[] a, int[] b, int[] c) { if (a[0] == b[0]) { if (c[0] == a[0]) return 0; else if (c[0] > a[0]) return 1; else return -1; } if (a[0] > b[0]) (a, b) = (b, a); var res = Area2(a, c) + Area2(c, b) - Area2(a, b); if (res == 0) return 0; if (res > 0) return 1; return -1; } static long Area2(int[] a, int[] b) { return (long)(a[1] + b[1]) * (b[0] - a[0]); } static double Length(int[] a, int[] b) { return Math.Sqrt(Math.Pow(a[0] - b[0], 2) + Math.Pow(a[1] - b[1], 2)); } }