結果

問題 No.3005 トレミーの問題
ユーザー sasa8uyauya
提出日時 2025-01-17 22:43:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 2,007 ms
コンパイル使用メモリ 81,464 KB
実行使用メモリ 51,968 KB
最終ジャッジ日時 2025-01-17 22:43:41
合計ジャッジ時間 3,223 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

p=[tuple(map(int,input().split())) for i in range(4)]

def X(a,b,c):
  ax,ay=a
  bx,by=b
  cx,cy=c
  return (ax-cx)*(by-cy)-(ay-cy)*(bx-cx)

def C(p):
  p.sort()
  c1=[]
  for np in p:
    while len(c1)>=2 and X(np,c1[-2],c1[-1])>=0:
      c1.pop()
    c1+=[np]
  p.reverse()
  c2=[]
  for np in p:
    while len(c2)>=2 and X(np,c2[-2],c2[-1])>=0:
      c2.pop()
    c2+=[np]
  c1.pop()
  c2.pop()
  return c1+c2

p=C(p)
if len(p)<4:
  print("NO")
  exit()
d=lambda p1,p2:(p1[0]-p2[0])**2+(p1[1]-p2[1])**2
A=d(p[0],p[1])*d(p[2],p[3])
B=d(p[1],p[2])*d(p[3],p[0])
C=d(p[0],p[2])*d(p[1],p[3])
print(["NO","YES"][C-A-B>=0 and 4*A*B==(C-A-B)**2])
0