結果

問題 No.2376 障害物競プロ
ユーザー MichirakaraMichirakara
提出日時 2023-06-30 13:04:47
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,527 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 87,364 KB
実行使用メモリ 83,836 KB
最終ジャッジ日時 2023-10-11 03:54:13
合計ジャッジ時間 122,745 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
71,656 KB
testcase_01 AC 86 ms
71,784 KB
testcase_02 AC 84 ms
75,020 KB
testcase_03 AC 85 ms
71,468 KB
testcase_04 AC 627 ms
78,592 KB
testcase_05 AC 940 ms
78,704 KB
testcase_06 AC 791 ms
78,920 KB
testcase_07 AC 2,487 ms
80,336 KB
testcase_08 AC 2,551 ms
80,048 KB
testcase_09 AC 2,538 ms
80,616 KB
testcase_10 AC 2,439 ms
79,832 KB
testcase_11 AC 2,588 ms
79,932 KB
testcase_12 AC 2,575 ms
79,988 KB
testcase_13 AC 2,469 ms
79,828 KB
testcase_14 AC 2,530 ms
80,248 KB
testcase_15 AC 2,188 ms
79,664 KB
testcase_16 AC 2,549 ms
79,944 KB
testcase_17 AC 2,613 ms
79,636 KB
testcase_18 AC 2,793 ms
81,736 KB
testcase_19 AC 3,493 ms
81,260 KB
testcase_20 AC 3,848 ms
83,836 KB
testcase_21 TLE -
testcase_22 AC 1,748 ms
80,460 KB
testcase_23 AC 1,724 ms
79,752 KB
testcase_24 AC 605 ms
78,740 KB
testcase_25 AC 429 ms
78,688 KB
testcase_26 AC 655 ms
78,708 KB
testcase_27 AC 670 ms
78,336 KB
testcase_28 AC 1,138 ms
79,168 KB
testcase_29 AC 440 ms
78,980 KB
testcase_30 AC 1,583 ms
80,868 KB
testcase_31 AC 790 ms
79,108 KB
testcase_32 AC 324 ms
79,828 KB
testcase_33 AC 717 ms
79,660 KB
testcase_34 AC 664 ms
79,124 KB
testcase_35 AC 244 ms
78,468 KB
testcase_36 AC 2,032 ms
79,552 KB
testcase_37 AC 1,286 ms
80,248 KB
testcase_38 AC 644 ms
78,856 KB
testcase_39 AC 2,242 ms
80,272 KB
testcase_40 AC 1,765 ms
79,784 KB
testcase_41 AC 478 ms
79,004 KB
testcase_42 AC 3,233 ms
81,072 KB
testcase_43 AC 3,326 ms
81,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt

N,M=map(int,input().split())
xy = []
for i in range(N):
    x1,y1,x2,y2=map(int,input().split())
    xy.append(((x1,y1),(x2,y2)))

#ワーシャルフロイド
dp = [[100000000000000000000] * (N + N) for _ in range(N + N)]
for i in range(N + N):
    for j in range(N + N):
        if i == j:
            dp[i][j] = 0
            continue
        xy1 = xy[i % N][i // N]
        xy2 = xy[j % N][j // N]
        flag = True
        for k in range(N):
            xy3 = xy[k][0]
            xy4 = xy[k][1]
            if xy3 in [xy1, xy2] or xy4 in [xy1, xy2]:
                continue

            s = (xy1[0] - xy2[0]) * (xy3[1] - xy1[1]) - (xy1[1] - xy2[1]) * (
                xy3[0] - xy1[0]
            )
            t = (xy1[0] - xy2[0]) * (xy4[1] - xy1[1]) - (xy1[1] - xy2[1]) * (
                xy4[0] - xy1[0]
            )
            s2 = (xy3[0] - xy4[0]) * (xy1[1] - xy3[1]) - (xy3[1] - xy4[1]) * (
                xy1[0] - xy3[0]
            )
            t2 = (xy3[0] - xy4[0]) * (xy2[1] - xy3[1]) - (xy3[1] - xy4[1]) * (
                xy2[0] - xy3[0]
            )
            if not(s * t >= 0 or s2 * t2 >= 0):
                flag = False
                break
        if flag:
            dp[i][j] = sqrt((xy1[0] - xy2[0]) ** 2 + (xy1[1] - xy2[1]) ** 2)
for k in range(N + N):
    for i in range(N + N):
        for j in range(N + N):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

for _ in range(M):
	a,b,c,d=map(int,input().split())
	print(dp[a-1+(b-1)*N][c-1+(d-1)*N])
0