結果
| 問題 |
No.2602 Real Collider
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-12 22:28:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 895 ms / 2,000 ms |
| コード長 | 1,489 bytes |
| コンパイル時間 | 319 ms |
| コンパイル使用メモリ | 82,044 KB |
| 実行使用メモリ | 77,008 KB |
| 最終ジャッジ日時 | 2024-09-27 23:03:08 |
| 合計ジャッジ時間 | 30,238 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 78 |
ソースコード
# https://tjkendev.github.io/procon-library/python/geometry/circles_associated_with_triangle.html
def circumcircle(P1, P2, P3):
x1, y1 = P1
x2, y2 = P2
x3, y3 = P3
a = 2 * (x1 - x2)
b = 2 * (y1 - y2)
p = x1**2 - x2**2 + y1**2 - y2**2
c = 2 * (x1 - x3)
d = 2 * (y1 - y3)
q = x1**2 - x3**2 + y1**2 - y3**2
det = a * d - b * c
if det == 0:
return None
x = d * p - b * q
y = a * q - c * p
if det < 0:
x = -x
y = -y
det = -det
r2 = (x - x1 * det) ** 2 + (y - y1 * det) ** 2
return x, y, r2, det
Q = int(input())
xa, ya, xb, yb, xc, yc = map(int, input().split())
res = circumcircle((xa, ya), (xb, yb), (xc, yc))
if res is None:
Ps = [(xa, ya), (xb, yb), (xc, yc)]
Ps.sort()
x1, y1 = Ps[0]
x2, y2 = Ps[2]
cx = x1 + x2
cy = y1 + y2
det = 2
r2 = (cx - 2 * x1) ** 2 + (cy - 2 * y1) ** 2
else:
cx, cy, r2, det = res
for i in range(3):
xa, xb, xc = xc, xa, xb
ya, yb, yc = yc, ya, yb
xx = xa + xb
yy = ya + yb
dd = 2
rr = (xx - 2 * xa) ** 2 + (yy - 2 * ya) ** 2
rr2 = (xx - 2 * xc) ** 2 + (yy - 2 * yc) ** 2
if rr2 > rr:
continue
if rr * det * det < r2 * dd * dd:
cx = xx
cy = yy
r2 = rr
det = dd
for _ in range(Q):
x, y = map(int, input().split())
x *= det
y *= det
d2 = (x - cx) ** 2 + (y - cy) ** 2
if d2 <= r2:
print("Yes")
else:
print("No")