結果
問題 | No.1497 Triangle |
ユーザー | tatyam |
提出日時 | 2021-05-02 02:25:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 550 ms / 2,000 ms |
コード長 | 2,794 bytes |
コンパイル時間 | 324 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 112,104 KB |
最終ジャッジ日時 | 2024-07-20 10:34:38 |
合計ジャッジ時間 | 14,768 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
54,784 KB |
testcase_01 | AC | 44 ms
54,272 KB |
testcase_02 | AC | 44 ms
54,600 KB |
testcase_03 | AC | 155 ms
78,248 KB |
testcase_04 | AC | 230 ms
78,476 KB |
testcase_05 | AC | 194 ms
78,348 KB |
testcase_06 | AC | 45 ms
54,656 KB |
testcase_07 | AC | 44 ms
54,656 KB |
testcase_08 | AC | 61 ms
67,072 KB |
testcase_09 | AC | 74 ms
71,232 KB |
testcase_10 | AC | 45 ms
54,144 KB |
testcase_11 | AC | 45 ms
54,400 KB |
testcase_12 | AC | 45 ms
54,656 KB |
testcase_13 | AC | 45 ms
54,912 KB |
testcase_14 | AC | 44 ms
54,784 KB |
testcase_15 | AC | 45 ms
54,784 KB |
testcase_16 | AC | 45 ms
54,784 KB |
testcase_17 | AC | 45 ms
54,912 KB |
testcase_18 | AC | 48 ms
54,528 KB |
testcase_19 | AC | 46 ms
55,168 KB |
testcase_20 | AC | 58 ms
61,696 KB |
testcase_21 | AC | 51 ms
61,952 KB |
testcase_22 | AC | 507 ms
111,896 KB |
testcase_23 | AC | 114 ms
77,440 KB |
testcase_24 | AC | 344 ms
86,920 KB |
testcase_25 | AC | 185 ms
78,268 KB |
testcase_26 | AC | 94 ms
74,112 KB |
testcase_27 | AC | 523 ms
111,492 KB |
testcase_28 | AC | 343 ms
86,952 KB |
testcase_29 | AC | 253 ms
80,136 KB |
testcase_30 | AC | 151 ms
102,912 KB |
testcase_31 | AC | 155 ms
104,192 KB |
testcase_32 | AC | 395 ms
110,844 KB |
testcase_33 | AC | 403 ms
111,368 KB |
testcase_34 | AC | 451 ms
111,496 KB |
testcase_35 | AC | 456 ms
111,832 KB |
testcase_36 | AC | 455 ms
111,408 KB |
testcase_37 | AC | 468 ms
112,104 KB |
testcase_38 | AC | 429 ms
111,764 KB |
testcase_39 | AC | 434 ms
111,536 KB |
testcase_40 | AC | 472 ms
111,424 KB |
testcase_41 | AC | 488 ms
111,276 KB |
testcase_42 | AC | 550 ms
112,008 KB |
testcase_43 | AC | 486 ms
111,536 KB |
testcase_44 | AC | 172 ms
78,044 KB |
testcase_45 | AC | 425 ms
111,164 KB |
testcase_46 | AC | 477 ms
111,528 KB |
testcase_47 | AC | 472 ms
111,876 KB |
testcase_48 | AC | 540 ms
111,428 KB |
testcase_49 | AC | 513 ms
111,500 KB |
testcase_50 | AC | 518 ms
111,932 KB |
ソースコード
from collections import defaultdict from math import * EPS = 1e-10 INF = float("inf") N = int(input()) P = [tuple(map(int, input().split())) for i in range(N)] P.sort(reverse=True) def cross(i, j, k): x0, y0 = P[i] x1, y1 = P[j] x2, y2 = P[k] x1 -= x0 x2 -= x0 y1 -= y0 y2 -= y0 return x1 * y2 - x2 * y1 def dot(i, j, k): x0, y0 = P[i] x1, y1 = P[j] x2, y2 = P[k] x1 -= x0 x2 -= x0 y1 -= y0 y2 -= y0 return x1 * x2 + y1 * y2 def normal(i, j): return atan2(P[j][1] - P[i][1], P[j][0] - P[i][0]) + pi / 2 class Line: def __init__(self): self.mn = INF self.mx = -INF self.rev = False def update(self, sl): if sl < 0: sl += 2 * pi if self.rev and sl < pi: sl += 2 * pi if self.mn > sl: self.mn = sl if self.mx < sl: self.mx = sl assert pi > self.mx - self.mn >= 0 lines = defaultdict(Line) for i in range(N - 1): if P[i][0] != P[i + 1][0]: lines[(1 << i + 1) - 1].rev = True for i in range(N): for j in range(N): if i == j: continue bit1 = 0 bit2 = 0 for k in range(N): c = cross(i, j, k) if c > 0: bit1 ^= 1 << k bit2 ^= 1 << k elif c == 0: if dot(i, j, k) > 0: bit1 ^= 1 << k else: bit2 ^= 1 << k theta = normal(i, j) lines[bit1].update(theta - EPS) lines[bit2].update(theta + EPS) lines = list(lines.items()) ans = [False] * (1 << N) ans[0] = ans[-1] = True for bit1, _ in lines: for bit2, _ in lines: ans[bit1 & bit2] = True def solve(l1, r1, l2, r2, l3, r3): if l1 > l2: l1, l2 = l2, l1 r1, r2 = r2, r1 if l2 > l3: l2, l3 = l3, l2 r2, r3 = r3, r2 if l1 > l2: l1, l2 = l2, l1 r1, r2 = r2, r1 if max(r1, r2, r3) - min(l1, l2, l3) < pi: return False l1 += 2 * pi r1 += 2 * pi if max(r1, r2, r3) - min(l1, l2, l3) < pi: return False l2 += 2 * pi r2 += 2 * pi if max(r1, r2, r3) - min(l1, l2, l3) < pi: return False return True L = len(lines) for i in range(L): bit1, l1 = lines[i] for j in range(i): bit2, l2 = lines[j] if not (bit1 & bit2 and bit1 & ~bit2 and ~bit1 & bit2): continue for k in range(j): bit3, l3 = lines[k] if not (bit1 & bit2 & bit3 and bit1 & bit2 & ~bit3 and bit1 & ~bit2 & bit3 and ~bit1 & bit2 & bit3): continue if solve(l1.mn, l1.mx, l2.mn, l2.mx, l3.mn, l3.mx): ans[bit1 & bit2 & bit3] = True print(sum(ans))