結果
| 問題 |
No.2602 Real Collider
|
| コンテスト | |
| ユーザー |
strangerxxx
|
| 提出日時 | 2024-01-13 00:14:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,406 bytes |
| コンパイル時間 | 254 ms |
| コンパイル使用メモリ | 82,196 KB |
| 実行使用メモリ | 77,568 KB |
| 最終ジャッジ日時 | 2024-09-28 00:34:48 |
| 合計ジャッジ時間 | 12,342 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 1 |
| other | AC * 55 WA * 23 |
ソースコード
def resolve():
import sys
input = sys.stdin.readline
MOD = 1000000007
q = int(input())
xa, ya, xb, yb, xc, yc = map(int, input().split())
c = circumcenter((xa, ya), (xb, yb), (xc, yc))
delta = 1e-6
d = distance(c, (xa, ya))
for _ in range(q):
x, y = map(int, input().split())
print("Yes" if distance(c, (x, y)) - delta <= d else "No")
def circumcenter(pa, pb, pc, ignore=False):
# 外心
a, b, c = side_length(pa, pb, pc)
try:
return barycentric_coordinate(
pa,
pb,
pc,
sin_a(a, b, c) * cos_a(a, b, c),
sin_a(b, c, a) * cos_a(b, c, a),
sin_a(c, a, b) * cos_a(c, a, b),
ignore,
)
except:
if ignore:
return []
else:
raise ValueError("points on a straight line")
def barycentric_coordinate(pa, pb, pc, ga, gb, gc, ignore=False):
# △BCP:△CAP:△ABP=ga:gb:gcであるときの点Pの座標
try:
g = ga + gb + gc
return [(a * ga + b * gb + c * gc) / g for a, b, c in zip(pa, pb, pc)]
except:
if ignore:
return []
else:
raise ValueError("points on a straight line")
def side_length(pa, pb, pc):
# 3辺の長さ
return distance(pc, pb), distance(pa, pc), distance(pa, pb)
def area(a, b, c):
# 面積
s = (a + b + c) / 2
return (s * (s - a) * (s - b) * (s - c)) ** 0.5
def sin_a(a, b, c):
# sin∠BAC
s = area(a, b, c)
return max(min(s * 2 / b / c, 1), -1)
def cos_a(a, b, c):
# cos∠BAC
return max(min((b**2 + c**2 - a**2) / (2 * b * c), 1), -1)
def sin_o(pa, pb):
# sin∠AOB
a, b, c = side_length([0] * len(pa), pa, pb)
return sin_a(a, b, c)
def cos_o(pa, pb):
# cos∠AOB
a, b, c = side_length([0] * len(pa), pa, pb)
return cos_a(a, b, c)
def sin_t(pa, pb, pc):
# 3つの角のsin
a, b, c = side_length(pa, pb, pc)
s = area(a, b, c)
return s * 2 / b / c, s * 2 / c / a, s * 2 / a / b
def cos_t(pa, pb, pc):
# 3つの角のcos
a, b, c = side_length(pa, pb, pc)
return cos_a(a, b, c), cos_a(b, c, a), cos_a(c, a, b)
def distance(pa, pb):
return sum([(i - j) ** 2 for i, j in zip(pa, pb)]) ** 0.5
def midpoint(pa, pb):
return [(x + y) / 2 for x, y in zip(pa, pb)]
if __name__ == "__main__":
resolve()
strangerxxx