結果

問題 No.199 星を描こう
ユーザー convexineqconvexineq
提出日時 2021-05-22 22:41:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 54,108 KB
最終ジャッジ日時 2024-04-19 06:10:33
合計ジャッジ時間 2,223 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,620 KB
testcase_01 AC 37 ms
53,128 KB
testcase_02 AC 38 ms
52,660 KB
testcase_03 AC 38 ms
52,824 KB
testcase_04 AC 38 ms
53,856 KB
testcase_05 AC 37 ms
52,288 KB
testcase_06 AC 36 ms
52,196 KB
testcase_07 AC 35 ms
52,656 KB
testcase_08 AC 36 ms
53,908 KB
testcase_09 AC 37 ms
52,332 KB
testcase_10 AC 37 ms
54,108 KB
testcase_11 AC 37 ms
52,264 KB
testcase_12 AC 37 ms
52,000 KB
testcase_13 AC 37 ms
53,280 KB
testcase_14 AC 37 ms
53,160 KB
testcase_15 AC 36 ms
52,876 KB
testcase_16 AC 36 ms
52,196 KB
testcase_17 AC 38 ms
52,812 KB
testcase_18 AC 37 ms
52,992 KB
testcase_19 AC 38 ms
53,124 KB
testcase_20 AC 37 ms
53,432 KB
testcase_21 AC 38 ms
52,852 KB
testcase_22 AC 38 ms
52,592 KB
testcase_23 AC 37 ms
52,584 KB
testcase_24 AC 37 ms
52,660 KB
testcase_25 AC 37 ms
52,808 KB
testcase_26 AC 38 ms
52,940 KB
testcase_27 AC 36 ms
52,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def convex_hull(points):
    def is_anticlockwise(i,j,k):
        """
        i,j,k がこの向きで反時計回りなら true
        """
        xi,yi = points[i]
        xj,yj = points[j]
        xk,yk = points[k]
        return (xj-xi)*(yk-yj) > (yj-yi)*(xk-xj) 

    n = len(points)
    points.sort()
    size = 0
    lst = []
    for i in range(n):
        while size > 1:
            if is_anticlockwise(lst[-2],lst[-1],i):
                break
            size -= 1
            lst.pop()
        lst.append(i)
        size += 1

    size = 0
    for i in range(n-1)[::-1]:
        while size:
            if is_anticlockwise(lst[-2],lst[-1],i):
                break
            size -= 1
            lst.pop()
        lst.append(i)
        size += 1
    return lst[:-1]

xy = [tuple(map(int,input().split())) for _ in range(5)]
lst = convex_hull(xy)
print("YES" if len(lst)==5 else "NO")
0