結果
| 問題 | 
                            No.3005 トレミーの問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-01-17 22:13:59 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 229 ms / 2,000 ms | 
| コード長 | 1,016 bytes | 
| コンパイル時間 | 799 ms | 
| コンパイル使用メモリ | 81,988 KB | 
| 実行使用メモリ | 83,712 KB | 
| 最終ジャッジ日時 | 2025-01-17 22:14:17 | 
| 合計ジャッジ時間 | 8,426 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 | 
ソースコード
from decimal import Decimal,ROUND_HALF_UP
import itertools
import math
from dataclasses import dataclass
@dataclass
class Point:
    x: int
    y: int
def length(P,Q):
    return math.sqrt(abs(P.x-Q.x)**2+abs(P.y-Q.y)**2)
P=[]
P.append(Point(*map(int,input().split())))
P.append(Point(*map(int,input().split())))
P.append(Point(*map(int,input().split())))
P.append(Point(*map(int,input().split())))
for a,b,c,d in itertools.permutations(range(4)):
    if (P[a].y-P[c].y)*(P[b].x-P[a].x)==(P[b].y-P[a].y)*(P[a].x-P[c].x) or \
        (P[a].y-P[c].y)*(P[d].x-P[a].x)==(P[d].y-P[a].y)*(P[a].x-P[c].x):
        # 4点が同一直線上にある場合は同一円周上にない
        continue
    # トレミーの定理
    l=Decimal(length(P[a],P[c])*length(P[b],P[d])).quantize(Decimal("0.000001"),rounding=ROUND_HALF_UP)
    r=Decimal(length(P[a],P[d])*length(P[b],P[c])+length(P[a],P[b])*length(P[d],P[c])).quantize(Decimal("0.000001"),rounding=ROUND_HALF_UP)
    if l==r:
        exit(print("YES"))
print("NO")