結果

問題 No.2376 障害物競プロ
ユーザー MichirakaraMichirakara
提出日時 2023-06-13 13:16:37
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,525 bytes
コンパイル時間 1,149 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 87,128 KB
最終ジャッジ日時 2023-09-23 07:31:47
合計ジャッジ時間 104,885 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,076 KB
testcase_01 AC 75 ms
71,340 KB
testcase_02 AC 79 ms
75,004 KB
testcase_03 WA -
testcase_04 AC 628 ms
78,300 KB
testcase_05 AC 931 ms
78,724 KB
testcase_06 AC 766 ms
78,764 KB
testcase_07 AC 2,449 ms
80,320 KB
testcase_08 AC 2,482 ms
79,676 KB
testcase_09 AC 2,407 ms
80,464 KB
testcase_10 AC 2,429 ms
79,864 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2,318 ms
79,728 KB
testcase_14 AC 2,418 ms
79,524 KB
testcase_15 AC 2,093 ms
79,320 KB
testcase_16 AC 2,449 ms
79,616 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1,695 ms
80,148 KB
testcase_23 AC 1,681 ms
79,444 KB
testcase_24 AC 610 ms
78,604 KB
testcase_25 AC 420 ms
78,520 KB
testcase_26 AC 660 ms
78,332 KB
testcase_27 AC 646 ms
78,448 KB
testcase_28 AC 1,002 ms
78,756 KB
testcase_29 AC 432 ms
78,436 KB
testcase_30 AC 1,537 ms
80,512 KB
testcase_31 AC 775 ms
78,928 KB
testcase_32 AC 318 ms
79,984 KB
testcase_33 AC 703 ms
79,352 KB
testcase_34 AC 652 ms
79,112 KB
testcase_35 AC 239 ms
78,092 KB
testcase_36 AC 2,003 ms
79,484 KB
testcase_37 AC 1,266 ms
80,052 KB
testcase_38 AC 588 ms
78,552 KB
testcase_39 AC 2,308 ms
80,020 KB
testcase_40 AC 1,741 ms
79,792 KB
testcase_41 AC 471 ms
78,592 KB
testcase_42 AC 3,127 ms
81,620 KB
testcase_43 AC 3,152 ms
81,652 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