結果

問題 No.2376 障害物競プロ
ユーザー MichirakaraMichirakara
提出日時 2023-06-13 13:19:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,554 bytes
コンパイル時間 1,803 ms
コンパイル使用メモリ 86,276 KB
実行使用メモリ 112,812 KB
最終ジャッジ日時 2023-09-23 07:28:46
合計ジャッジ時間 23,776 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 252 ms
91,040 KB
testcase_01 AC 281 ms
91,428 KB
testcase_02 AC 485 ms
95,040 KB
testcase_03 WA -
testcase_04 AC 1,352 ms
101,488 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from decimal import *

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

#ワーシャルフロイド
dp = [[Decimal("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] = Decimal("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] = ((xy1[0] - xy2[0]) ** 2 + (xy1[1] - xy2[1]) ** 2).sqrt()
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