結果

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

ソースコード

diff #

import cmath

def dist(l1,l2):
    a,b,c,d=l1[0],l1[1],l2[0],l2[1]
    return ((c-a)**2+(d-b)**2)**0.5

la=list(map(int,input().split()))
lb=list(map(int,input().split()))
lc=list(map(int,input().split()))
ld=list(map(int,input().split()))

l=[la,lb,lc,ld]
arr=sorted(l,key=lambda x:cmath.phase(complex(x[0],x[1])))
la,lb,lc,ld=arr[0],arr[1],arr[2],arr[3]

import itertools

def ar(points):
    area=0
    n=len(points)
    for i in range(n):
        x1,y1=points[i]
        x2,y2=points[(i+1)%n]
        area+=x1*y2-x2*y1
    return abs(area)/2

def f(pts):
    for perm in itertools.permutations(pts, 4):
        if ar(perm) != 0:
            return True

    return False

pts=[(la[0],la[1]),(lb[0],lb[1]),(lc[0],lc[1]),(ld[0],ld[1])]
if not f(pts):
    print('NO')
    exit()

AB=dist(la,lb)
CD=dist(lc,ld)
AD=dist(la,ld)
BC=dist(lc,lb)
AC=dist(la,lc)
BD=dist(lb,ld)

n1=AB*CD+AD*BC
N1='{0:.9f}'.format(n1)
N2='{0:.9f}'.format(AC*BD)

if N1==N2:
    print('YES')
else:
    print('NO')
0