結果

問題 No.2628 Shrinkage
ユーザー rlangevinrlangevin
提出日時 2024-02-18 12:50:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,204 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 53,588 KB
最終ジャッジ日時 2024-02-18 12:50:24
合計ジャッジ時間 2,385 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys
input = sys.stdin.readline

from math import gcd
def frac(x, y):
    if x == 0:
        return (0, 1)
    if y == 0:
        return (1, 0)
    g = gcd(x, y)
    x, y = x // g, y // g
    if x < 0:
        return (-x, -y)
    return (x, y)

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        
def cross(a, b, c, d):
    s = (a.x - b.x) * (c.y - a.y) - (a.y - b.y) * (c.x - a.x)
    t = (a.x - b.x) * (d.y - a.y) - (a.y - b.y) * (d.x - a.x)
    if s * t > 0:
        return False
    
    s = (c.x - d.x) * (a.y - c.y) - (c.y - d.y) * (a.x - c.x)
    t = (c.x - d.x) * (b.y - c.y) - (c.y - d.y) * (b.x - c.x)
    if s * t > 0:
        return False
    
    return True


T = int(input())
for _ in range(T):
    x1, y1, x2, y2, X1, Y1, X2, Y2 = map(int, input().split())
    dx1 = X1 - x1
    dx2 = X2 - x2
    dy1 = Y1 - y1
    dy2 = Y2 - y2
    a = Point(x1, y1)
    b = Point(x2, y2)
    c = Point(X1, Y1)
    d = Point(X2, Y2)
    if cross(a, c, b, d) or (frac(x2 - x1, y2 - y1) != frac(X2 - X1, Y2 - Y1)):
        print("No")
    elif (x2 - x1) ** 2 + (y2 - y1) ** 2 <= (X2 - X1) ** 2 + (Y2 - Y1) ** 2:
        print("No")
    else:
        print("Yes")
0