結果

問題 No.2602 Real Collider
ユーザー るこーそー
提出日時 2025-01-01 02:46:20
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 4,030 bytes
コンパイル時間 2,678 ms
コンパイル使用メモリ 81,976 KB
実行使用メモリ 80,496 KB
最終ジャッジ日時 2025-01-01 02:47:41
合計ジャッジ時間 77,976 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 77 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

class Fraction:
    def __init__(self,numerator,denominator=1):
        if isinstance(numerator,Fraction):
            self.numerator=numerator.numerator
            self.denominator=numerator.denominator
        else:
            if isinstance(numerator,str):
                integer,decimal=numerator.split('.')
                numerator=int(integer)*pow(10,len(decimal))+int(decimal)
                denominator=pow(10,len(decimal))
            self.numerator=numerator
            self.denominator=denominator
            self._reduction()
    def _gcd(self,a,b):
        while b:
            a,b=b,a%b
        return a
    def _reduction(self):
       gcd=self._gcd(self.numerator,self.denominator)
       self.numerator//=gcd
       self.denominator//=gcd
       if self.denominator<0:
           self.numerator*=-1
           self.denominator*=-1
    def __add__(self,other):
        other=Fraction(other)
        numerator=self.numerator*other.denominator + other.numerator*self.denominator
        denominator=self.denominator*other.denominator
        return Fraction(numerator,denominator)
    def __sub__(self,other):
        other=Fraction(other)
        return self+(-other)
    def __mul__(self,other):
        other=Fraction(other)
        numerator=self.numerator*other.numerator
        denominator=self.denominator*other.denominator
        return Fraction(numerator,denominator)
    def __truediv__(self,other):
        other=Fraction(other)
        numerator=self.numerator*other.denominator
        denominator=self.denominator*other.numerator
        return Fraction(numerator,denominator)
    def __radd__(self,other):
        return self+other
    def __rsub__(self,other):
        return self-other
    def __rmul__(self,other):
        return self*other
    def __rfloordiv__(self,other):
        return self/other
    def __iadd__(self,other):
        self=self+other
        return self
    def __isub__(self,other):
        self=self-other
        return self
    def __imul__(self,other):
        self=self*other
        return self
    def __ifloordiv__(self,other):
        self=self/other
        return self
    def __lt__(self,other):
        other=Fraction(other)
        return self.numerator*other.denominator < other.numerator*self.denominator
    def __gt__(self,other):
        other=Fraction(other)
        return self.numerator*other.denominator > other.numerator*self.denominator
    def __le__(self,other):
        return not(self>other)
    def __ge__(self,other):
        return not(self<other)     
    def __neg__(self):
        return Fraction(-self.numerator,self.denominator)
    def __pos__(self):
        return Fraction(self.numerator,self.denominator)
    def __float__(self):
        return self.numerator/self.denominator
    def __int__(self):
        return self.numerator//self.denominator
    def __repr__(self):
        return f"{self.numerator}/{self.denominator}"

def main():  
    q=int(input())
    xa,ya,xb,yb,xc,yc=map(int,input().split())
    ab2=(xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)
    bc2=(xb-xc)*(xb-xc)+(yb-yc)*(yb-yc)
    ca2=(xc-xa)*(xc-xa)+(yc-ya)*(yc-ya)
    if ab2>=bc2+ca2:
        ox=Fraction(xa+xb,2)
        oy=Fraction(ya+yb,2)
        r2=(ox-xa)*(ox-xa)+(oy-ya)*(oy-ya)
    elif bc2>=ab2+ca2:
        ox=Fraction(xc+xb,2)
        oy=Fraction(yc+yb,2)
        r2=(ox-xc)*(ox-xc)+(oy-yc)*(oy-yc)
    elif ca2>=ab2+bc2:
        ox=Fraction(xc+xa,2)
        oy=Fraction(yc+ya,2)
        r2=(ox-xa)*(ox-xa)+(oy-ya)*(oy-ya)
    else:
        ox=Fraction((xa*xa+ya*ya)*(yb-yc)+(xb*xb+yb*yb)*(yc-ya)+(xc*xc+yc*yc)*(ya-yb),((yb-yc)*(xa-xb)-(ya-yb)*(xb-xc))*2)
        oy=Fraction((xa*xa+ya*ya)*(xb-xc)+(xb*xb+yb*yb)*(xc-xa)+(xc*xc+yc*yc)*(xa-xb),((xb-xc)*(ya-yb)-(xa-xb)*(yb-yc))*2)
        r2=(ox-xa)*(ox-xa)+(oy-ya)*(oy-ya)
    for _ in range(q):
        x,y=map(int,input().split())
        rr2=(ox-x)*(ox-x)+(oy-y)*(oy-y)
        if rr2<=r2:
            print('Yes')
        else:
            print('No')

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