結果
| 問題 |
No.3154 convex polygon judge
|
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2025-05-20 21:40:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 848 ms / 2,000 ms |
| コード長 | 718 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 82,480 KB |
| 実行使用メモリ | 113,428 KB |
| 最終ジャッジ日時 | 2025-05-20 21:40:33 |
| 合計ジャッジ時間 | 6,741 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 |
ソースコード
def cross3(a, b, c):
return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])
# ps = [(x, y), ...]: ソートされた座標list
def convex_hull(ps):
qs = []
L = 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(L-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
N = int(input())
XY = sorted([list(map(int, input().split())) for _ in range(N)])
C = convex_hull(XY)
if len(C) == N+1:
print("Yes")
else:
print("No")
detteiuu