結果

問題 No.2376 障害物競プロ
ユーザー mkawa2mkawa2
提出日時 2023-09-24 21:56:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,271 ms / 4,000 ms
コード長 1,730 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 83,216 KB
最終ジャッジ日時 2023-09-24 21:57:50
合計ジャッジ時間 77,057 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,464 KB
testcase_01 AC 75 ms
71,700 KB
testcase_02 AC 74 ms
71,844 KB
testcase_03 AC 75 ms
71,740 KB
testcase_04 AC 283 ms
78,716 KB
testcase_05 AC 410 ms
79,284 KB
testcase_06 AC 365 ms
79,600 KB
testcase_07 AC 1,241 ms
80,744 KB
testcase_08 AC 1,236 ms
80,928 KB
testcase_09 AC 1,223 ms
81,044 KB
testcase_10 AC 1,177 ms
80,484 KB
testcase_11 AC 1,237 ms
80,740 KB
testcase_12 AC 1,271 ms
80,924 KB
testcase_13 AC 1,098 ms
81,024 KB
testcase_14 AC 1,178 ms
80,340 KB
testcase_15 AC 1,030 ms
80,392 KB
testcase_16 AC 1,165 ms
80,484 KB
testcase_17 AC 1,186 ms
80,484 KB
testcase_18 AC 1,235 ms
80,764 KB
testcase_19 AC 621 ms
81,080 KB
testcase_20 AC 820 ms
82,516 KB
testcase_21 AC 791 ms
82,356 KB
testcase_22 AC 771 ms
80,368 KB
testcase_23 AC 852 ms
79,920 KB
testcase_24 AC 254 ms
78,172 KB
testcase_25 AC 213 ms
78,732 KB
testcase_26 AC 262 ms
78,512 KB
testcase_27 AC 316 ms
79,540 KB
testcase_28 AC 475 ms
79,276 KB
testcase_29 AC 231 ms
78,768 KB
testcase_30 AC 838 ms
80,360 KB
testcase_31 AC 385 ms
79,124 KB
testcase_32 AC 203 ms
78,060 KB
testcase_33 AC 398 ms
79,592 KB
testcase_34 AC 374 ms
79,772 KB
testcase_35 AC 141 ms
78,156 KB
testcase_36 AC 1,046 ms
80,800 KB
testcase_37 AC 569 ms
79,680 KB
testcase_38 AC 298 ms
79,260 KB
testcase_39 AC 1,153 ms
80,880 KB
testcase_40 AC 913 ms
79,796 KB
testcase_41 AC 279 ms
79,376 KB
testcase_42 AC 789 ms
83,216 KB
testcase_43 AC 786 ms
82,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 63)
# md = 10**9+7
md = 998244353

def norm(i,j):
    x,y=xy[i]
    s,t=xy[j]
    return ((x-s)**2+(y-t)**2)**0.5

def ok(i,j):
    for k in range(n):
        if cross(i,j,k):return False
    return True

def cross(i,j,k):
    x,y=xy[i]
    s,t=xy[j]
    a,b=xy[k*2]
    c,d=xy[k*2+1]
    if ((c-x)*(t-y)-(d-y)*(s-x))*((s-x)*(b-y)-(t-y)*(a-x))<=0:return False
    if ((x-a)*(d-b)-(y-b)*(c-a))*((c-a)*(t-b)-(d-b)*(s-a))<=0:return False
    return True

n,m=LI()
n2=n*2
xy=[None]*n2
for i in range(n):
    x,y,s,t=LI()
    xy[i*2]=(x,y)
    xy[i*2+1]=(s,t)

dist=[inf]*(n2*n2)
for i in range(n2):
    for j in range(i+1):
        if i==j:
            dist[i*n2+j]=0
        elif ok(i,j):
            dist[i*n2+j]=dist[j*n2+i]=norm(i,j)

for j in range(n2):
    for i in range(n2):
        for k in range(i):
            d=dist[i*n2+j]+dist[j*n2+k]
            if d<dist[i*n2+k]:dist[i*n2+k]=dist[k*n2+i]=d

for _ in range(m):
    i,p,j,q=LI1()
    i=i*2+p
    j=j*2+q
    print(f"{dist[i*n2+j]:.7f}")
0