結果

問題 No.2602 Real Collider
ユーザー strangerxxxstrangerxxx
提出日時 2024-05-01 17:44:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 5,859 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 84,248 KB
最終ジャッジ日時 2024-05-01 17:45:36
合計ジャッジ時間 46,486 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
54,540 KB
testcase_01 AC 38 ms
55,024 KB
testcase_02 AC 38 ms
54,264 KB
testcase_03 AC 39 ms
56,456 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 648 ms
82,072 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 508 ms
79,620 KB
testcase_16 AC 613 ms
81,184 KB
testcase_17 AC 731 ms
81,896 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 275 ms
78,396 KB
testcase_27 WA -
testcase_28 AC 351 ms
78,316 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 612 ms
80,636 KB
testcase_32 AC 536 ms
81,120 KB
testcase_33 AC 622 ms
80,056 KB
testcase_34 AC 647 ms
83,068 KB
testcase_35 AC 503 ms
79,712 KB
testcase_36 AC 289 ms
78,916 KB
testcase_37 AC 646 ms
80,924 KB
testcase_38 AC 689 ms
80,576 KB
testcase_39 AC 632 ms
80,128 KB
testcase_40 AC 432 ms
79,720 KB
testcase_41 AC 691 ms
81,428 KB
testcase_42 AC 598 ms
80,860 KB
testcase_43 AC 619 ms
82,932 KB
testcase_44 AC 733 ms
81,964 KB
testcase_45 AC 553 ms
81,352 KB
testcase_46 AC 485 ms
79,224 KB
testcase_47 AC 754 ms
80,528 KB
testcase_48 AC 594 ms
80,248 KB
testcase_49 AC 482 ms
79,752 KB
testcase_50 AC 441 ms
79,236 KB
testcase_51 AC 445 ms
79,772 KB
testcase_52 AC 397 ms
79,460 KB
testcase_53 AC 615 ms
80,928 KB
testcase_54 AC 544 ms
80,616 KB
testcase_55 AC 572 ms
81,260 KB
testcase_56 AC 547 ms
79,784 KB
testcase_57 AC 560 ms
79,932 KB
testcase_58 AC 402 ms
80,992 KB
testcase_59 AC 633 ms
80,120 KB
testcase_60 AC 395 ms
78,436 KB
testcase_61 AC 600 ms
81,756 KB
testcase_62 AC 705 ms
81,964 KB
testcase_63 AC 810 ms
84,248 KB
testcase_64 AC 755 ms
81,636 KB
testcase_65 AC 580 ms
81,148 KB
testcase_66 AC 707 ms
80,624 KB
testcase_67 AC 543 ms
82,268 KB
testcase_68 AC 549 ms
82,476 KB
testcase_69 AC 469 ms
81,028 KB
testcase_70 AC 452 ms
80,640 KB
testcase_71 AC 473 ms
79,504 KB
testcase_72 AC 600 ms
81,268 KB
testcase_73 AC 615 ms
81,120 KB
testcase_74 AC 609 ms
81,376 KB
testcase_75 AC 722 ms
81,208 KB
testcase_76 AC 585 ms
80,428 KB
testcase_77 AC 601 ms
80,212 KB
testcase_78 AC 731 ms
82,020 KB
testcase_79 AC 707 ms
83,588 KB
testcase_80 AC 788 ms
83,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math


def resolve():
    import sys

    input = sys.stdin.readline
    MOD = 1000000007
    q = int(input())
    xa, ya, xb, yb, xc, yc = map(int, input().split())
    c = circumcenter2((xa, ya), (xb, yb), (xc, yc))
    d = distance(c, (xa, ya))
    for _ in range(q):
        x, y = map(int, input().split())
        print("Yes" if distance(c, (x, y)) <= d else "No")


class Fraction:
    def __init__(self, a: int = 0, b: int = 1) -> None:
        if isinstance(a, Fraction):
            self.a, self.b = a.a, a.b
            return
        a, b = int(a), int(b)
        if b == 0:
            raise ZeroDivisionError(f"{a}/{b}")
        if b < 0:
            a, b = -a, -b
        self.a, self.b = a, b
        self._reducion()

    def _reducion(self):
        g = math.gcd(self.a, self.b)
        self.a //= g
        self.b //= g

    def __add__(self, other):
        if isinstance(other, Fraction):
            g = math.gcd(self.b, other.b)
            x = other.b // g * self.a
            y = self.b // g * other.a
            return Fraction(x + y, self.b // g * other.b)
        return Fraction(self.a + other * self.b, self.b)

    def __iadd__(self, other):
        if isinstance(other, Fraction):
            g = math.gcd(self.b, other.b)
            self.a *= other.b // g
            self.a += self.b // g * other.a
            self.b *= other.b // g
        else:
            self.a += other * self.b
        self._reducion()
        return self

    __radd__ = __add__

    def __sub__(self, other):
        if isinstance(other, Fraction):
            return self.__add__(-other)
        return self.__add__(-other)

    def __isub__(self, other):
        if isinstance(other, Fraction):
            return self.__iadd__(-other.a, other.b)
        return self.__iadd__(-other)

    def __rsub__(self, other):
        return -self + other

    def __mul__(self, other):
        if isinstance(other, Fraction):
            return Fraction(self.a * other.a, self.b * other.b)
        else:
            return Fraction(self.a * other, self.b)

    def __imul__(self, other):
        if isinstance(other, Fraction):
            self.a *= other.a
            self.b *= other.b
        else:
            self.a *= other
        self._reducion()
        return self

    __rmul__ = __mul__

    def __floordiv__(self, other):
        if isinstance(other, Fraction):
            return self.__mul__(other.inverse())
        return Fraction(self.a, self.b * other)

    def __ifloordiv__(self, other):
        if isinstance(other, Fraction):
            return self.__imul__(other.inverse())
        self.b *= other
        self._reducion()
        return self

    def __rfloordiv__(self, other):
        return self.inverse() * other

    __truediv__ = __floordiv__
    __itruediv__ = __ifloordiv__
    __rtruediv__ = __rfloordiv__

    def __pow__(self, other):
        if isinstance(other, Fraction):
            if other.b == 1:
                return self.__pow__(other.a)
            raise NotImplementedError
        return Fraction(self.a**other, self.b**other)

    def __ipow__(self, other):
        if isinstance(other, Fraction):
            if other.b == 1:
                return self.__ipow__(other.a)
            raise NotImplementedError
        self.a **= other
        self.b **= other
        return self

    def __rpow__(self, other):
        if self.b != 1:
            raise NotImplementedError
        return other**self.a

    def __floor__(self) -> int:
        return self.a // self.b

    def __ceil__(self) -> int:
        return (self.a + self.b - 1) // self.b

    __int__ = __floor__

    def __float__(self):
        return self.a / self.b

    def inverse(self):
        if self.a == 0:
            raise ZeroDivisionError(f"tring to calcuate inverse of {self.a}/{self.b}")
        return Fraction(self.b, self.a)

    def __pos__(self):
        return Fraction(self.a, self.b)

    def __neg__(self):
        return Fraction(-self.a, self.b)

    def __abs__(self):
        return Fraction(abs(self.a), self.b)

    def __eq__(self, other) -> bool:
        if isinstance(other, Fraction):
            return self.a == other.a and self.b == other.b
        return self.a == self.b * other

    def __gt__(self, other):
        if isinstance(other, Fraction):
            return self.a * other.b > other.a * self.b
        return self.a > self.b * other

    def __ge__(self, other):
        if isinstance(other, Fraction):
            return self.a * other.b >= other.a * self.b
        return self.a >= self.b * other

    def __lt__(self, other):
        if isinstance(other, Fraction):
            return self.a * other.b < other.a * self.b
        return self.a < self.b * other

    def __le__(self, other):
        if isinstance(other, Fraction):
            return self.a * other.b <= other.a * self.b
        return self.a <= self.b * other

    def __str__(self) -> str:
        return f"{self.a}/{self.b}"

    __repr__ = __str__

    def __hash__(self) -> int:
        return hash(self.__str__())


def distance(pa, pb):
    return sum([(i - j) ** 2 for i, j in zip(pa, pb)]) ** 0.5


def circumcenter2(pa, pb, pc):
    # 外心
    x0 = (
        (pa[0] ** 2 + pa[1] ** 2) * (pb[1] - pc[1])
        + (pb[0] ** 2 + pb[1] ** 2) * (pc[1] - pa[1])
        + (pc[0] ** 2 + pc[1] ** 2) * (pa[1] - pb[1])
    )
    y0 = 2 * ((pb[1] - pc[1]) * (pa[0] - pb[0]) - (pa[1] - pb[1]) * (pb[0] - pc[0]))
    x1 = (
        (pa[1] ** 2 + pa[0] ** 2) * (pb[0] - pc[0])
        + (pb[1] ** 2 + pb[0] ** 2) * (pc[0] - pa[0])
        + (pc[1] ** 2 + pc[0] ** 2) * (pa[0] - pb[0])
    )
    y1 = 2 * ((pb[0] - pc[0]) * (pa[1] - pb[1]) - (pa[0] - pb[0]) * (pb[1] - pc[1]))
    return (
        Fraction(x0, y0) if y0 else 0,
        Fraction(x1, y1) if y1 else 0,
    )


if __name__ == "__main__":
    resolve()
0