結果
| 問題 | No.3664 Manhattan Circumcenter |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-08-30 15:51:23 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,526 bytes |
| 記録 | |
| コンパイル時間 | 237 ms |
| コンパイル使用メモリ | 96,372 KB |
| 実行使用メモリ | 79,104 KB |
| 最終ジャッジ日時 | 2026-08-30 15:51:30 |
| 合計ジャッジ時間 | 6,741 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 36 |
ソースコード
points = [tuple([int(s) * 2 for s in input().split()]) for _ in range(3)]
if len(set(points)) <= 2:
print(-1)
exit()
def sign(x):
if x > 0:
return 1
elif x == 0:
return 0
else:
return -1
def line(p, q):
px, py = p
qx, qy = q
mx, my = (px + qx) // 2, (py + qy) // 2
if px == qx:
a, b, c = 1, 0, -my
elif py == qy:
a, b, c = 0, 1, -mx
elif sign(px - qx) == sign(py - qy):
a, b, c = 1, 1, -mx - my
else:
a, b, c = -1, 1, mx - my
return a, b, c
def cross(ln1, ln2):
a1, b1, c1 = ln1
a2, b2, c2 = ln2
if a1 * b2 - a2 * b1 == 0:
if b1 * c2 - b2 * c1 == 0:
return -1, []
else:
return 0, []
x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)
y = (a2 * c1 - a1 * c2) / (a1 * b2 - a2 * b1)
return 1, [(x, y)]
def same(p, q):
px, py = p
qx, qy = q
return abs(px - qx) == abs(py - qy)
def inner(p, q, v):
px, _ = p
qx, _ = q
vx, _ = v
return min(px, qx) < vx < max(px, qx)
ln1 = line(points[0], points[1])
ln2 = line(points[1], points[2])
size, res = cross(ln1, ln2)
if size == 1:
x, y = res[0]
if same(points[0], points[1]):
if not inner(points[0], points[1], (x, y)):
print(-1)
exit()
if same(points[1], points[2]):
if not inner(points[1], points[2], (x, y)):
print(-1)
exit()
print(1)
print(x / 2, y / 2)
else:
print(size)