結果
問題 | No.199 星を描こう |
ユーザー | Mao-beta |
提出日時 | 2024-04-05 01:07:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 2,465 bytes |
コンパイル時間 | 427 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 56,576 KB |
最終ジャッジ日時 | 2024-10-01 00:44:09 |
合計ジャッジ時間 | 2,960 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
56,192 KB |
testcase_01 | AC | 45 ms
56,320 KB |
testcase_02 | AC | 45 ms
56,064 KB |
testcase_03 | AC | 49 ms
55,936 KB |
testcase_04 | AC | 45 ms
56,064 KB |
testcase_05 | AC | 46 ms
56,448 KB |
testcase_06 | AC | 46 ms
56,576 KB |
testcase_07 | AC | 45 ms
56,064 KB |
testcase_08 | AC | 45 ms
56,576 KB |
testcase_09 | AC | 46 ms
55,936 KB |
testcase_10 | AC | 47 ms
56,192 KB |
testcase_11 | AC | 46 ms
56,528 KB |
testcase_12 | AC | 47 ms
56,448 KB |
testcase_13 | AC | 45 ms
56,192 KB |
testcase_14 | AC | 46 ms
56,320 KB |
testcase_15 | AC | 46 ms
56,448 KB |
testcase_16 | AC | 47 ms
56,192 KB |
testcase_17 | AC | 46 ms
56,192 KB |
testcase_18 | AC | 47 ms
56,576 KB |
testcase_19 | AC | 46 ms
56,320 KB |
testcase_20 | AC | 47 ms
56,448 KB |
testcase_21 | AC | 48 ms
56,064 KB |
testcase_22 | AC | 46 ms
56,064 KB |
testcase_23 | AC | 47 ms
56,576 KB |
testcase_24 | AC | 46 ms
56,320 KB |
testcase_25 | AC | 47 ms
56,192 KB |
testcase_26 | AC | 48 ms
56,448 KB |
testcase_27 | AC | 45 ms
56,320 KB |
ソースコード
import sys import math import bisect from heapq import heapify, heappop, heappush from collections import deque, defaultdict, Counter from functools import lru_cache from itertools import accumulate, combinations, permutations, product sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 MOD99 = 998244353 input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() SMI = lambda: input().split() SLI = lambda: list(SMI()) EI = lambda m: [NLI() for _ in range(m)] def convex(Vs): """ :param Vs(sorted by x): [[x1, y1], ... [xn, yn]] :return: upper, lower """ def cross(x1, y1, x2, y2): return x1 * y2 - y1 * x2 def is_ccw(x1, y1, x2, y2): return cross(x1, y1, x2, y2) >= 0 N = len(Vs) upper = deque() upper.append(Vs[0]) upper.append(Vs[1]) for i in range(2, N): V3 = Vs[i] x3, y3 = V3 while len(upper) >= 2: V2 = upper.pop() V1 = upper.pop() x2, y2 = V2 x1, y1 = V1 upper.append(V1) if not is_ccw(x2-x1, y2-y1, x3-x2, y3-y2): upper.append(V2) upper.append(V3) break if len(upper) < 2: upper.append(V3) lower = deque() lower.append(Vs[-1]) lower.append(Vs[-2]) for i in range(N-3, -1, -1): V3 = Vs[i] x3, y3 = V3 while len(lower) >= 2: V2 = lower.pop() V1 = lower.pop() x2, y2 = V2 x1, y1 = V1 lower.append(V1) if not is_ccw(x2-x1, y2-y1, x3-x2, y3-y2): lower.append(V2) lower.append(V3) break if len(lower) < 2: lower.append(V3) return upper, lower def convex_perimeter(upper: deque, lower: deque): res = 0 x, y = upper.popleft() while upper: xx, yy = upper.popleft() res += math.sqrt((x - xx) ** 2 + (y - yy) ** 2) x, y = xx, yy x, y = lower.popleft() while lower: xx, yy = lower.popleft() res += math.sqrt((x - xx) ** 2 + (y - yy) ** 2) x, y = xx, yy return res def main(): XY = EI(5) XY.sort() upper, lower = convex(XY) if len(upper) + len(lower) == 7: print("YES") else: print("NO") if __name__ == "__main__": main()