結果

問題 No.3005 トレミーの問題
ユーザー tassei903
提出日時 2025-01-17 21:57:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,057 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2025-01-17 21:57:43
合計ジャッジ時間 2,493 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
# input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################


def dist(a, b):
    return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2
def check(a, b, c, d):
    Z = dist(a, c) * dist(b, d) - dist(a, b) * dist(c, d) - dist(a, d) * dist(b, c)
    R2 = 4 * dist(a, b) * dist(c, d) * dist(a, d) * dist(b, c)
    return Z >= 0 and Z * Z == R2

def sub(a, b):
    return (a[0]-b[0], a[1]-b[1])
def det(a, b):
    return a[0] * b[1] - a[1] * b[0]

def check2(a, b, c):
    ab = sub(a, b)
    ac = sub(a, c)
    return det(ab, ac) == 0

n = 4
p = [na() for i in range(n)]

from itertools import permutations

for q in permutations(p, 3):
    if check2(*q):
        NO()
        exit()

for q in permutations(p, 4):
    if check(*q):
        YES()
        break
else:
    NO()
0