結果

問題 No.199 星を描こう
ユーザー n_knuun_knuu
提出日時 2015-04-29 17:38:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,321 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 11,092 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2023-09-19 04:07:00
合計ジャッジ時間 1,732 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,268 KB
testcase_01 WA -
testcase_02 AC 17 ms
8,360 KB
testcase_03 AC 17 ms
8,264 KB
testcase_04 AC 17 ms
8,248 KB
testcase_05 AC 16 ms
8,248 KB
testcase_06 AC 17 ms
8,432 KB
testcase_07 AC 16 ms
8,076 KB
testcase_08 AC 16 ms
8,448 KB
testcase_09 AC 17 ms
8,416 KB
testcase_10 AC 17 ms
8,216 KB
testcase_11 AC 17 ms
8,260 KB
testcase_12 AC 16 ms
8,408 KB
testcase_13 AC 16 ms
8,352 KB
testcase_14 AC 16 ms
8,348 KB
testcase_15 WA -
testcase_16 AC 17 ms
8,256 KB
testcase_17 WA -
testcase_18 AC 16 ms
8,344 KB
testcase_19 WA -
testcase_20 AC 17 ms
8,256 KB
testcase_21 AC 16 ms
8,396 KB
testcase_22 AC 17 ms
8,260 KB
testcase_23 AC 16 ms
8,344 KB
testcase_24 AC 16 ms
8,400 KB
testcase_25 AC 17 ms
8,396 KB
testcase_26 AC 16 ms
8,248 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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')
0