結果

問題 No.2628 Shrinkage
ユーザー ShirotsumeShirotsume
提出日時 2024-02-16 23:42:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,458 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 88,124 KB
最終ジャッジ日時 2024-02-16 23:42:38
合計ジャッジ時間 5,913 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
88,124 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353
from fractions import Fraction
def line_cross_point(P0, P1, Q0, Q1):
    x0, y0 = P0; x1, y1 = P1
    x2, y2 = Q0; x3, y3 = Q1
    a0 = x1 - x0; b0 = y1 - y0
    a2 = x3 - x2; b2 = y3 - y2

    d = a0*b2 - a2*b0
    if d == 0:
        # two lines are parallel
        return None

    # s = sn/d
    sn = b2 * (x2-x0) - a2 * (y2-y0)
    # t = tn/d
    #tn = b0 * (x2-x0) - a0 * (y2-y0)
    return x0 + Fraction(a0*sn,d), y0 + Fraction(b0*sn,d)
def solve():
    x1, y1, x2, y2, X1, Y1, X2, Y2 = mi()
    if (x1 == X1) and (y1 == Y1) and (x2 == X2) and (y2 == Y2):
        print('Yes')
        return
    elif (x1 - x2) * (Y1 - Y2) != (X1 - X2) * (y1 - y2):
        print('No')
        return
    elif (x2 - x1) ** 2 + (y2 - y1) ** 2 <= (X1 - X2) ** 2 + (Y2 - Y1) ** 2:
        print('No')
        return
    else:
        lx, ly = line_cross_point((x1, y1), (X1, Y1), (x2, y2), (X2, Y2))
        d1 = (x1 - lx) ** 2 + (y1 - ly) ** 2
        d2 = (X1 - lx) ** 2 + (Y1 - ly) ** 2
        D1 = (x2 - lx) ** 2 + (y2 - ly) ** 2
        D2 = (X2 - lx) ** 2 + (Y2 - ly) ** 2
        if d1 * D2 == d2 * D1:
            print('Yes')
        else:
            print('No')
        
        
for _ in range(ii()):
    solve()
0