結果
| 問題 |
No.3154 convex polygon judge
|
| コンテスト | |
| ユーザー |
timi
|
| 提出日時 | 2025-05-20 23:22:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 698 ms / 2,000 ms |
| コード長 | 739 bytes |
| コンパイル時間 | 443 ms |
| コンパイル使用メモリ | 82,380 KB |
| 実行使用メモリ | 103,008 KB |
| 最終ジャッジ日時 | 2025-05-20 23:22:14 |
| 合計ジャッジ時間 | 7,125 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 |
ソースコード
N=int(input())
A=[]
for i in range(N):
x,y=map(int, input().split())
A.append((x,y))
A=sorted(A,key=lambda x: x[1])
A=sorted(A,key=lambda x: x[0])
def cross3(a, b, c):
return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])
def convex_hull(ps):
qs = []
N = len(ps)
for p in ps:
# 一直線上で高々2点にする場合は ">=" にする
while len(qs) > 1 and cross3(qs[-1], qs[-2], p) >= 0:
qs.pop()
qs.append(p)
t = len(qs)
for i in range(N-2, -1, -1):
p = ps[i]
while len(qs) > t and cross3(qs[-1], qs[-2], p) >= 0:
qs.pop()
qs.append(p)
return qs
ans= convex_hull(A)
if len(ans)==N+1:
print('Yes')
else:
print('No')
timi