結果

問題 No.2602 Real Collider
ユーザー mkawa2mkawa2
提出日時 2024-07-22 22:31:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,117 ms / 2,000 ms
コード長 2,852 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,032 KB
実行使用メモリ 95,900 KB
最終ジャッジ日時 2024-07-22 22:32:19
合計ジャッジ時間 48,092 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
88,260 KB
testcase_01 AC 146 ms
88,340 KB
testcase_02 AC 141 ms
88,440 KB
testcase_03 AC 147 ms
88,632 KB
testcase_04 AC 138 ms
88,384 KB
testcase_05 AC 142 ms
88,444 KB
testcase_06 AC 139 ms
88,496 KB
testcase_07 AC 138 ms
88,360 KB
testcase_08 AC 145 ms
88,328 KB
testcase_09 AC 142 ms
88,336 KB
testcase_10 AC 1,117 ms
95,900 KB
testcase_11 AC 638 ms
93,036 KB
testcase_12 AC 392 ms
90,848 KB
testcase_13 AC 312 ms
90,156 KB
testcase_14 AC 434 ms
91,124 KB
testcase_15 AC 518 ms
92,784 KB
testcase_16 AC 688 ms
92,692 KB
testcase_17 AC 726 ms
94,516 KB
testcase_18 AC 365 ms
90,412 KB
testcase_19 AC 390 ms
90,368 KB
testcase_20 AC 675 ms
92,700 KB
testcase_21 AC 343 ms
90,496 KB
testcase_22 AC 362 ms
90,700 KB
testcase_23 AC 352 ms
90,456 KB
testcase_24 AC 354 ms
90,528 KB
testcase_25 AC 354 ms
90,436 KB
testcase_26 AC 371 ms
90,308 KB
testcase_27 AC 379 ms
90,732 KB
testcase_28 AC 437 ms
90,764 KB
testcase_29 AC 390 ms
90,632 KB
testcase_30 AC 388 ms
90,436 KB
testcase_31 AC 662 ms
93,516 KB
testcase_32 AC 599 ms
93,512 KB
testcase_33 AC 678 ms
93,452 KB
testcase_34 AC 701 ms
92,892 KB
testcase_35 AC 535 ms
92,680 KB
testcase_36 AC 365 ms
90,236 KB
testcase_37 AC 683 ms
93,908 KB
testcase_38 AC 721 ms
93,484 KB
testcase_39 AC 686 ms
94,044 KB
testcase_40 AC 473 ms
91,404 KB
testcase_41 AC 751 ms
93,084 KB
testcase_42 AC 658 ms
92,696 KB
testcase_43 AC 599 ms
92,400 KB
testcase_44 AC 768 ms
93,140 KB
testcase_45 AC 606 ms
92,660 KB
testcase_46 AC 550 ms
92,044 KB
testcase_47 AC 730 ms
94,020 KB
testcase_48 AC 612 ms
92,180 KB
testcase_49 AC 540 ms
92,792 KB
testcase_50 AC 484 ms
91,676 KB
testcase_51 AC 519 ms
92,160 KB
testcase_52 AC 434 ms
90,928 KB
testcase_53 AC 668 ms
93,788 KB
testcase_54 AC 570 ms
91,648 KB
testcase_55 AC 616 ms
91,844 KB
testcase_56 AC 593 ms
91,704 KB
testcase_57 AC 590 ms
92,348 KB
testcase_58 AC 433 ms
90,984 KB
testcase_59 AC 674 ms
93,744 KB
testcase_60 AC 526 ms
92,736 KB
testcase_61 AC 596 ms
92,296 KB
testcase_62 AC 695 ms
93,140 KB
testcase_63 AC 778 ms
93,480 KB
testcase_64 AC 807 ms
93,696 KB
testcase_65 AC 569 ms
93,216 KB
testcase_66 AC 719 ms
92,636 KB
testcase_67 AC 478 ms
91,424 KB
testcase_68 AC 545 ms
91,844 KB
testcase_69 AC 455 ms
91,584 KB
testcase_70 AC 490 ms
91,412 KB
testcase_71 AC 544 ms
92,424 KB
testcase_72 AC 669 ms
92,804 KB
testcase_73 AC 623 ms
92,192 KB
testcase_74 AC 658 ms
93,336 KB
testcase_75 AC 712 ms
94,304 KB
testcase_76 AC 647 ms
93,024 KB
testcase_77 AC 653 ms
92,332 KB
testcase_78 AC 771 ms
93,252 KB
testcase_79 AC 731 ms
93,032 KB
testcase_80 AC 778 ms
93,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

from math import gcd
from fractions import Fraction

# t=0 2点
# t=1 傾き分子、傾き分母、1点
class Line:
    def __init__(self, x1, y1, x2, y2, t=0):
        a, b, c = y2-y1, x1-x2, x2*y1-x1*y2
        if t == 1: a, b, c = x1*2, -y1*2, y1*y2-x1*x2
        if a < 0: a, b, c = -a, -b, -c
        g = gcd(a, gcd(b, c))
        self.a, self.b, self.c = a//g, b//g, c//g

    def __eq__(self, other):
        return self.a == other.a and self.b == other.b and self.c == other.c

    def online(self, x, y):
        return self.a*x+self.b*y+self.c == 0

    # 交点の座標(分数)
    def crossf(self, other):
        if self == other: return "same", "same"
        if self.a*other.b == self.b*other.a: return "none", "none"
        return Fraction(self.c*other.b - self.b*other.c,self.b*other.a - self.a*other.b) , Fraction(self.c*other.a - self.a*other.c,self.a*other.b - self.b*other.a)

    # 交点の座標(実数)
    def crossr(self, other):
        if self == other: return "same", "same"
        if self.a*other.b == self.b*other.a: return "none", "none"
        return (self.c*other.b - self.b*other.c)/(self.b*other.a - self.a*other.b) , (self.c*other.a - self.a*other.c)/(self.a*other.b - self.b*other.a)

def d2(i,j):
    x,y=abc[i],abc[i+1]
    s,t=abc[j],abc[j+1]
    return (x-s)**2+(y-t)**2

def midpoint(i,j):
    x,y=abc[i],abc[i+1]
    s,t=abc[j],abc[j+1]
    return Fraction(x+s,2),Fraction(y+t,2)

def trend(i,j):
    x,y=abc[i],abc[i+1]
    s,t=abc[j],abc[j+1]
    return y-t,x-s

q=II()
abc=LI()
a=d2(0,2)
b=d2(0,4)
c=d2(2,4)
mx=max(a,b,c)
# print(a,b,c)
if 2*mx>a+b+c:
    if mx==a:[ox,oy],r=midpoint(0,2),Fraction(a,4)
    if mx==b:[ox,oy],r=midpoint(0,4),Fraction(b,4)
    if mx==c:[ox,oy],r=midpoint(2,4),Fraction(c,4)
else:
    n,d=trend(0,2)
    x,y=abc[0]+abc[2],abc[1]+abc[3]
    l1=Line(d,-n,x,y,1)
    n,d=trend(0,4)
    x,y=abc[0]+abc[4],abc[1]+abc[5]
    l2=Line(d,-n,x,y,1)
    ox,oy=l1.crossf(l2)
    r=(ox-abc[0])**2+(oy-abc[1])**2
# print(ox,oy,r)

for _ in range(q):
    x,y=LI()
    print("Yes" if (x-ox)**2+(y-oy)**2<=r else "No")
0