結果

問題 No.3154 convex polygon judge
ユーザー ゼット
提出日時 2025-05-20 21:57:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 416 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 93,888 KB
最終ジャッジ日時 2025-05-20 21:57:52
合計ジャッジ時間 5,392 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def get_angle(pt):
    return math.atan2(pt[1], pt[0])

def sort_points_clockwise(points):
    center = (sum(x for x, y in points) / len(points), sum(y for x, y in points) / len(points))
    return sorted(points, key=lambda point: -get_angle((point[0]-center[0], point[1]-center[1])))

points = [(985, 268), (112, 316), (998, 448), (1018, 453), (1279, 577), (1196, 477), (1161, 443), (986, 0), (830, 0), (983, 230), (998, 425), (998, 255)]
N=int(input())
L=[]
a=0
b=0
for i in range(N):
  x,y=map(int,input().split())
  L.append((x,y))
h = sort_points_clockwise(L)
result='Yes'
for i in range(N):
  a,b,c=h[i%N],h[(i+1)%N],h[(i+2)%N]
  d,e=[b[0]-a[0],b[1]-a[1]],[c[0]-b[0],c[1]-b[1]]
  score=d[0]*e[1]-d[1]*e[0]
  if score>=0:
    result='No'
print(result)
  
0