結果
問題 |
No.199 星を描こう
|
ユーザー |
![]() |
提出日時 | 2015-04-29 17:38:51 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,321 bytes |
コンパイル時間 | 81 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-05 16:42:12 |
合計ジャッジ時間 | 1,754 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 21 WA * 4 |
ソースコード
eps = 1e-10 def add(a, b): return 0 if abs(a + b) < eps * (abs(a) + abs(b)) else a + b class Point: def __init__(self, x, y): self.x = x self.y = y def __add__(self, p): return Point(add(self.x, p.x), add(self.y, p.y)) def __sub__(self, p): return Point(add(self.x, -p.x), add(self.y, -p.y)) def __mul__(self, d): return Point(self.x * d, self.y * d) def dot(self, p): return add(self.x * p.x, self.y * p.y) def det(self, p): return add(self.x * p.y, -self.y * p.x) def __str__(self): return "({}, {})".format(self.x, self.y) def convex_hull(ps, n): """ P(x, y) : point P n : number of point """ ps = [Point(x, y) for x, y in sorted([(p.x, p.y) for p in ps])] upper_hull = get_bounds(ps) ps.reverse() lower_hull = get_bounds(ps) del upper_hull[-1] del lower_hull[-1] upper_hull.extend(lower_hull) return upper_hull def get_bounds(ps): qs = [ps[0], ps[1]] for p in ps[2:]: while len(qs) > 1 and (qs[-1] - qs[-2]).det(p - qs[-1]) < 0: del qs[-1] qs.append(p) return qs qs = [] for i in range(5): x, y = map(int, input().split()) qs.append(Point(x, y)) qs = convex_hull(qs, 5) print('YES' if len(qs) == 5 else 'NO')