結果
問題 | No.2376 障害物競プロ |
ユーザー | poyon |
提出日時 | 2023-06-19 20:40:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,346 ms / 4,000 ms |
コード長 | 2,404 bytes |
コンパイル時間 | 377 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 82,304 KB |
最終ジャッジ日時 | 2024-07-16 07:31:09 |
合計ジャッジ時間 | 67,910 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,120 KB |
testcase_01 | AC | 41 ms
52,992 KB |
testcase_02 | AC | 44 ms
53,888 KB |
testcase_03 | AC | 41 ms
52,864 KB |
testcase_04 | AC | 314 ms
77,440 KB |
testcase_05 | AC | 526 ms
78,704 KB |
testcase_06 | AC | 398 ms
79,408 KB |
testcase_07 | AC | 980 ms
79,944 KB |
testcase_08 | AC | 973 ms
80,520 KB |
testcase_09 | AC | 941 ms
80,544 KB |
testcase_10 | AC | 949 ms
80,844 KB |
testcase_11 | AC | 1,025 ms
82,028 KB |
testcase_12 | AC | 1,006 ms
81,556 KB |
testcase_13 | AC | 863 ms
80,464 KB |
testcase_14 | AC | 1,029 ms
80,540 KB |
testcase_15 | AC | 873 ms
79,820 KB |
testcase_16 | AC | 927 ms
80,536 KB |
testcase_17 | AC | 1,188 ms
82,252 KB |
testcase_18 | AC | 1,089 ms
82,304 KB |
testcase_19 | AC | 1,346 ms
79,632 KB |
testcase_20 | AC | 1,262 ms
80,012 KB |
testcase_21 | AC | 1,278 ms
80,012 KB |
testcase_22 | AC | 702 ms
80,652 KB |
testcase_23 | AC | 643 ms
79,028 KB |
testcase_24 | AC | 259 ms
76,288 KB |
testcase_25 | AC | 246 ms
78,072 KB |
testcase_26 | AC | 283 ms
76,032 KB |
testcase_27 | AC | 389 ms
79,428 KB |
testcase_28 | AC | 485 ms
80,808 KB |
testcase_29 | AC | 307 ms
78,900 KB |
testcase_30 | AC | 629 ms
79,996 KB |
testcase_31 | AC | 420 ms
80,016 KB |
testcase_32 | AC | 266 ms
79,000 KB |
testcase_33 | AC | 369 ms
79,636 KB |
testcase_34 | AC | 349 ms
79,940 KB |
testcase_35 | AC | 135 ms
76,672 KB |
testcase_36 | AC | 721 ms
79,516 KB |
testcase_37 | AC | 581 ms
79,912 KB |
testcase_38 | AC | 340 ms
78,988 KB |
testcase_39 | AC | 886 ms
80,108 KB |
testcase_40 | AC | 649 ms
80,656 KB |
testcase_41 | AC | 334 ms
79,252 KB |
testcase_42 | AC | 1,227 ms
80,140 KB |
testcase_43 | AC | 1,218 ms
80,504 KB |
ソースコード
import math import sys input = sys.stdin.readline class Point: def __init__(self, x=0, y=0): self.x = x self.y = y def __iadd__(self, v): self.x += v.x self.y += v.y return self def __isub__(self, v): self.x -= v.x self.y -= v.y return self def __add__(self, v): return Point(self.x + v.x, self.y + v.y) def __sub__(self, v): return Point(self.x - v.x, self.y - v.y) def norm(a): return a.x * a.x + a.y * a.y def dot(a, b): return a.x * b.x + a.y * b.y def cross(a, b): return a.x * b.y - a.y * b.x def ccw(p0, p1, p2): a = p1 - p0 b = p2 - p0 if (cross(a, b) > 0): return 1 if (cross(a, b) < 0): return -1 if (dot(a, b) < 0): return 2 if (norm(a) < norm(b)): return -2 return 0 def is_intersected(p1, p2, p3, p4): return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0) and \ (ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0) def on_segment(p1, p2, p): return ccw(p1, p2, p) == 0 def main(): N, M = map(int, input().split()) x = [[0] * 2 for _ in range(N)] y = [[0] * 2 for _ in range(N)] for i in range(N): x[i][0], y[i][0], x[i][1], y[i][1] = map(int, input().split()) N2 = N * 2 inf = (1 << 30) G = [[inf] * N2 for _ in range(N2)] for i in range(N2): G[i][i] = 0 a, b = divmod(i, 2) x1 = x[a][b] y1 = y[a][b] p1 = Point(x1, y1) for j in range(i + 1, N2): c, d = divmod(j, 2) x2 = x[c][d] y2 = y[c][d] p2 = Point(x2, y2) ok = True for k in range(N): if k == a or k == c: continue p3 = Point(x[k][0], y[k][0]) p4 = Point(x[k][1], y[k][1]) if is_intersected(p1, p2, p3, p4): ok = False break if ok: G[i][j] = G[j][i] = math.hypot(x2 - x1, y2 - y1) for k in range(N2): for i in range(N2): for j in range(N2): G[i][j] = min(G[i][j], G[i][k] + G[k][j]) for i in range(M): a, b, c, d = map(int, input().split()) a -= 1 b -= 1 c -= 1 d -= 1 s = 2 * a + b t = 2 * c + d ans = G[s][t] print(ans) if __name__ == "__main__": main()