結果

問題 No.2602 Real Collider
ユーザー 👑 rin204rin204
提出日時 2024-01-12 22:28:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 922 ms / 2,000 ms
コード長 1,489 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,680 KB
最終ジャッジ日時 2024-01-12 22:29:41
合計ジャッジ時間 31,571 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,588 KB
testcase_01 AC 37 ms
53,588 KB
testcase_02 AC 37 ms
53,588 KB
testcase_03 AC 40 ms
53,588 KB
testcase_04 AC 38 ms
53,588 KB
testcase_05 AC 38 ms
53,588 KB
testcase_06 AC 37 ms
53,588 KB
testcase_07 AC 38 ms
53,588 KB
testcase_08 AC 36 ms
53,588 KB
testcase_09 AC 37 ms
53,588 KB
testcase_10 AC 922 ms
76,680 KB
testcase_11 AC 394 ms
76,424 KB
testcase_12 AC 280 ms
75,996 KB
testcase_13 AC 170 ms
75,996 KB
testcase_14 AC 298 ms
75,996 KB
testcase_15 AC 311 ms
76,424 KB
testcase_16 AC 443 ms
76,424 KB
testcase_17 AC 478 ms
76,424 KB
testcase_18 AC 234 ms
75,996 KB
testcase_19 AC 249 ms
75,996 KB
testcase_20 AC 557 ms
76,424 KB
testcase_21 AC 215 ms
75,996 KB
testcase_22 AC 242 ms
75,996 KB
testcase_23 AC 187 ms
75,996 KB
testcase_24 AC 261 ms
75,996 KB
testcase_25 AC 238 ms
75,996 KB
testcase_26 AC 318 ms
76,296 KB
testcase_27 AC 268 ms
75,996 KB
testcase_28 AC 476 ms
76,424 KB
testcase_29 AC 241 ms
75,996 KB
testcase_30 AC 255 ms
75,996 KB
testcase_31 AC 445 ms
76,424 KB
testcase_32 AC 396 ms
76,424 KB
testcase_33 AC 444 ms
76,424 KB
testcase_34 AC 457 ms
76,424 KB
testcase_35 AC 309 ms
76,296 KB
testcase_36 AC 310 ms
76,424 KB
testcase_37 AC 480 ms
76,424 KB
testcase_38 AC 487 ms
76,424 KB
testcase_39 AC 498 ms
76,424 KB
testcase_40 AC 270 ms
76,296 KB
testcase_41 AC 523 ms
76,424 KB
testcase_42 AC 430 ms
76,424 KB
testcase_43 AC 464 ms
76,424 KB
testcase_44 AC 531 ms
76,424 KB
testcase_45 AC 364 ms
76,296 KB
testcase_46 AC 347 ms
76,424 KB
testcase_47 AC 486 ms
76,424 KB
testcase_48 AC 384 ms
76,424 KB
testcase_49 AC 342 ms
76,424 KB
testcase_50 AC 285 ms
76,296 KB
testcase_51 AC 299 ms
76,424 KB
testcase_52 AC 232 ms
76,296 KB
testcase_53 AC 483 ms
76,424 KB
testcase_54 AC 364 ms
76,424 KB
testcase_55 AC 400 ms
76,424 KB
testcase_56 AC 394 ms
76,424 KB
testcase_57 AC 370 ms
76,424 KB
testcase_58 AC 226 ms
76,424 KB
testcase_59 AC 430 ms
76,424 KB
testcase_60 AC 404 ms
76,424 KB
testcase_61 AC 329 ms
76,424 KB
testcase_62 AC 455 ms
76,424 KB
testcase_63 AC 535 ms
76,424 KB
testcase_64 AC 570 ms
76,552 KB
testcase_65 AC 329 ms
76,296 KB
testcase_66 AC 482 ms
76,424 KB
testcase_67 AC 297 ms
76,296 KB
testcase_68 AC 302 ms
76,424 KB
testcase_69 AC 239 ms
76,296 KB
testcase_70 AC 268 ms
76,296 KB
testcase_71 AC 321 ms
76,424 KB
testcase_72 AC 439 ms
76,424 KB
testcase_73 AC 404 ms
76,424 KB
testcase_74 AC 450 ms
76,424 KB
testcase_75 AC 478 ms
76,424 KB
testcase_76 AC 423 ms
76,424 KB
testcase_77 AC 445 ms
76,424 KB
testcase_78 AC 523 ms
76,424 KB
testcase_79 AC 466 ms
76,424 KB
testcase_80 AC 516 ms
76,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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")
0