結果
問題 | No.2173 Nightcord |
ユーザー | chineristAC |
提出日時 | 2022-12-25 02:21:41 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,343 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 84,352 KB |
最終ジャッジ日時 | 2024-04-29 08:00:51 |
合計ジャッジ時間 | 20,883 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
55,936 KB |
testcase_01 | AC | 52 ms
56,320 KB |
testcase_02 | RE | - |
testcase_03 | AC | 1,363 ms
82,048 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | AC | 91 ms
77,440 KB |
testcase_11 | RE | - |
testcase_12 | AC | 100 ms
77,696 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | AC | 110 ms
77,952 KB |
testcase_16 | AC | 104 ms
77,696 KB |
testcase_17 | RE | - |
testcase_18 | AC | 96 ms
77,824 KB |
testcase_19 | RE | - |
testcase_20 | AC | 95 ms
77,184 KB |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 100 ms
77,696 KB |
testcase_24 | RE | - |
testcase_25 | AC | 100 ms
77,568 KB |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | AC | 106 ms
77,696 KB |
testcase_29 | RE | - |
testcase_30 | AC | 105 ms
77,952 KB |
testcase_31 | RE | - |
testcase_32 | AC | 696 ms
79,744 KB |
testcase_33 | AC | 1,208 ms
81,536 KB |
testcase_34 | AC | 1,298 ms
84,352 KB |
testcase_35 | AC | 703 ms
79,488 KB |
testcase_36 | AC | 816 ms
80,128 KB |
testcase_37 | AC | 1,147 ms
82,688 KB |
testcase_38 | AC | 265 ms
78,080 KB |
testcase_39 | AC | 655 ms
79,744 KB |
testcase_40 | AC | 1,266 ms
83,072 KB |
testcase_41 | AC | 833 ms
79,360 KB |
testcase_42 | AC | 840 ms
80,128 KB |
testcase_43 | AC | 183 ms
77,184 KB |
testcase_44 | AC | 54 ms
56,960 KB |
testcase_45 | AC | 394 ms
77,696 KB |
testcase_46 | AC | 525 ms
78,592 KB |
testcase_47 | AC | 518 ms
78,208 KB |
testcase_48 | AC | 293 ms
77,952 KB |
testcase_49 | AC | 88 ms
73,088 KB |
testcase_50 | AC | 161 ms
76,928 KB |
testcase_51 | AC | 556 ms
78,336 KB |
testcase_52 | AC | 82 ms
70,656 KB |
testcase_53 | AC | 584 ms
78,464 KB |
testcase_54 | AC | 784 ms
79,104 KB |
testcase_55 | AC | 238 ms
77,056 KB |
testcase_56 | AC | 396 ms
77,824 KB |
ソースコード
import sys,random,bisect from collections import deque,defaultdict,Counter from heapq import heapify,heappop,heappush from itertools import cycle, permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) def cross3(a, b, c): return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0]) # ps = [(x, y), ...]: ソートされた座標list def convex_hull(ps): qs = [] N = len(ps) for p in ps: # 一直線上で高々2点にする場合は ">=" にする while len(qs) > 1 and cross3(qs[-1], qs[-2], p) > 0: qs.pop() qs.append(p) t = len(qs) for i in range(N-2, -1, -1): p = ps[i] while len(qs) > t and cross3(qs[-1], qs[-2], p) > 0: qs.pop() qs.append(p) return qs # O(N) def inside_convex_polygon0(p0, qs): L = len(qs) D = [cross3(qs[i-1], p0, qs[i]) for i in range(L)] return all(e >= 0 for e in D) or all(e <= 0 for e in D) # O(log N) def inside_convex_polygon(p0, qs): L = len(qs) left = 1; right = L q0 = qs[0] while left+1 < right: mid = (left + right) >> 1 if cross3(q0, p0, qs[mid]) <= 0: left = mid else: right = mid if left == L-1: left -= 1 qi = qs[left]; qj = qs[left+1] v0 = cross3(q0, qi, qj) v1 = cross3(q0, p0, qj) v2 = cross3(q0, qi, p0) if v0 < 0: v1 = -v1; v2 = -v2 return 0 <= v1 and 0 <= v2 and v1 + v2 <= v0 def solve_3(N,K,star): for p in range(2): for x,y in star[p]: S = set() for xx,yy in star[p^1]: xx,yy = xx-x,yy-y g = gcd(xx,yy) xx,yy = xx//g,yy//g if (-xx,-yy) in S: return "Yes" S.add((xx,yy)) return "No" def solve_4(N,K,star): star[0].sort() star[1].sort() ch = [convex_hull(star[p]) for p in range(2)] for p in range(2): for x,y in star[p]: if inside_convex_polygon((x,y),ch[p^1]): return "Yes" assert False N,K = mi() star = [[] for p in range(2)] for _ in range(N): x,y,c = mi() star[c-1].append((x,y)) if K == 3: print(solve_3(N,K,star)) else: print(solve_4(N,K,star))