結果
問題 | No.199 星を描こう |
ユーザー |
|
提出日時 | 2015-04-29 00:29:35 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 1,346 bytes |
コンパイル時間 | 322 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-12-30 03:30:39 |
合計ジャッジ時間 | 2,175 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
def convex_hull(points): '''二次元平面上の点のリスト points の凸包を返す。Andrew のアルゴリズムを使用。 引数: points = [(x0, y0), (x1, y1),...] 点のリスト 同じ点は含まない(全て異なる点である)とする。 返り値: convex_hull = [(xi, yi), (xj, yj),...] 点のリスト。時計回りに並んでいる。 ''' points.sort() upper_bounds = get_bounds(points) points.reverse() lower_bounds = get_bounds(points) del upper_bounds[-1] del lower_bounds[-1] upper_bounds.extend(lower_bounds) return upper_bounds def get_bounds(points): bounds = [points[0], points[1]] for xi, yi in points[2:]: while len(bounds) > 1 and not is_convex(bounds, xi, yi): del bounds[-1] bounds.append((xi, yi)) return bounds def is_convex(bounds, x2, y2): x1, y1 = bounds[-1] x0, y0 = bounds[-2] return (x1 - x0) * (y2 - y1) < (y1 - y0) * (x2 - x1) def read_data(): points = [] for i in range(5): x, y = map(int, input().split()) points.append((x, y)) return points def is_star(points): return len(convex_hull(points)) == 5 if __name__ == "__main__": points = read_data() if is_star(points): print('YES') else: print('NO')