結果

問題 No.2602 Real Collider
ユーザー cleanttedcleantted
提出日時 2023-11-28 20:21:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 337 ms / 2,000 ms
コード長 2,445 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 121,728 KB
最終ジャッジ日時 2024-09-26 13:04:44
合計ジャッジ時間 24,964 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
90,240 KB
testcase_01 AC 162 ms
90,368 KB
testcase_02 AC 162 ms
90,368 KB
testcase_03 AC 166 ms
90,496 KB
testcase_04 AC 158 ms
90,368 KB
testcase_05 AC 168 ms
90,368 KB
testcase_06 AC 164 ms
90,368 KB
testcase_07 AC 162 ms
90,368 KB
testcase_08 AC 160 ms
90,368 KB
testcase_09 AC 162 ms
90,240 KB
testcase_10 AC 337 ms
121,728 KB
testcase_11 AC 262 ms
105,728 KB
testcase_12 AC 290 ms
109,056 KB
testcase_13 AC 232 ms
98,688 KB
testcase_14 AC 297 ms
110,336 KB
testcase_15 AC 256 ms
101,504 KB
testcase_16 AC 275 ms
105,344 KB
testcase_17 AC 284 ms
108,544 KB
testcase_18 AC 249 ms
103,040 KB
testcase_19 AC 289 ms
107,136 KB
testcase_20 AC 294 ms
109,184 KB
testcase_21 AC 266 ms
103,808 KB
testcase_22 AC 281 ms
105,984 KB
testcase_23 AC 259 ms
99,968 KB
testcase_24 AC 278 ms
105,216 KB
testcase_25 AC 255 ms
104,960 KB
testcase_26 AC 253 ms
101,632 KB
testcase_27 AC 286 ms
104,960 KB
testcase_28 AC 276 ms
107,648 KB
testcase_29 AC 279 ms
105,984 KB
testcase_30 AC 286 ms
106,624 KB
testcase_31 AC 279 ms
105,984 KB
testcase_32 AC 262 ms
105,088 KB
testcase_33 AC 269 ms
104,448 KB
testcase_34 AC 273 ms
106,368 KB
testcase_35 AC 251 ms
100,864 KB
testcase_36 AC 251 ms
101,504 KB
testcase_37 AC 289 ms
108,544 KB
testcase_38 AC 285 ms
105,600 KB
testcase_39 AC 282 ms
109,440 KB
testcase_40 AC 244 ms
97,664 KB
testcase_41 AC 292 ms
109,824 KB
testcase_42 AC 268 ms
102,656 KB
testcase_43 AC 276 ms
105,728 KB
testcase_44 AC 295 ms
110,208 KB
testcase_45 AC 260 ms
102,144 KB
testcase_46 AC 254 ms
101,120 KB
testcase_47 AC 285 ms
105,728 KB
testcase_48 AC 260 ms
104,320 KB
testcase_49 AC 250 ms
100,736 KB
testcase_50 AC 249 ms
98,688 KB
testcase_51 AC 247 ms
99,584 KB
testcase_52 AC 231 ms
97,408 KB
testcase_53 AC 274 ms
106,240 KB
testcase_54 AC 261 ms
102,144 KB
testcase_55 AC 271 ms
105,344 KB
testcase_56 AC 272 ms
104,832 KB
testcase_57 AC 262 ms
102,784 KB
testcase_58 AC 223 ms
95,488 KB
testcase_59 AC 269 ms
105,216 KB
testcase_60 AC 269 ms
105,472 KB
testcase_61 AC 254 ms
101,888 KB
testcase_62 AC 277 ms
105,856 KB
testcase_63 AC 287 ms
107,136 KB
testcase_64 AC 306 ms
108,416 KB
testcase_65 AC 254 ms
101,632 KB
testcase_66 AC 277 ms
109,056 KB
testcase_67 AC 240 ms
99,328 KB
testcase_68 AC 247 ms
99,584 KB
testcase_69 AC 230 ms
97,024 KB
testcase_70 AC 247 ms
99,200 KB
testcase_71 AC 256 ms
101,632 KB
testcase_72 AC 286 ms
105,088 KB
testcase_73 AC 261 ms
103,936 KB
testcase_74 AC 274 ms
106,112 KB
testcase_75 AC 285 ms
106,752 KB
testcase_76 AC 267 ms
102,784 KB
testcase_77 AC 275 ms
105,856 KB
testcase_78 AC 294 ms
109,696 KB
testcase_79 AC 279 ms
106,624 KB
testcase_80 AC 300 ms
108,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy
import heapq
import itertools
import math
import operator
import sys
from bisect import bisect, bisect_left, bisect_right, insort
from collections import Counter, deque
from fractions import Fraction
from functools import cmp_to_key, lru_cache, partial
from inspect import currentframe
from math import ceil, gcd, log10, pi, sqrt

# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
# mod = 10 ** 9 + 7
mod = 998244353
# mod = 1 << 128
# mod = 10 ** 30 + 1
INF = 1 << 61
DIFF = 10 ** -9
DX = [1, 0, -1, 0, 1, 1, -1, -1]
DY = [0, 1, 0, -1, 1, -1, 1, -1]

def read_values(): return tuple(map(int, input().split()))
def read_index(): return tuple(map(lambda x: int(x) - 1, input().split()))
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for _ in range(N)]
def dprint(*values): print(*values, file=sys.stderr)
def dprint2(*values):
    names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    dprint(", ".join(f"{names.get(id(value), '???')}={repr(value)}" for value in values))


def main():
    Q = int(input())
    XA, YA, XB, YB, XC, YC = read_list()
    L = read_lists(Q)

    def dot(x1, y1, x2, y2):
        return x1 * x2 + y1 * y2

    def rot(x1, y1, x2, y2):
        return x1 * y2 - x2 * y1

    def dist2(x1, y1, x2, y2):
        return (x1 - x2) ** 2 + (y1 - y2) ** 2
    
    def g(x1, y1, x2, y2, x3, y3):
        return dist2(x1, y1, x2, y2), dot(x3 - x1, y3 - y1, x3 - x2, y3 - y2), (x1, y1), (x2, y2), (x3, y3)

    _, c, A, B, C = max(
        g(XA, YA, XB, YB, XC, YC),
        g(XB, YB, XC, YC, XA, YA),
        g(XC, YC, XA, YA, XB, YB),
    )

    k1 = rot(*A, *B) + rot(*B, *C) + rot(*C, *A)

    if c <= 0:
        t1 = 0
        t2 = 1
    else:
        t1 = c ** 2
        t2 = dist2(*A, *C) * dist2(*B, *C)

    res = []
    for X, Y in L:
        s1 = dot(X - A[0], Y - A[1], X - B[0], Y - B[1])
        s2 = dist2(X, Y, *A) * dist2(X, Y, *B)
        k2 = rot(*A, *B) + rot(*B, X, Y) + rot(X, Y, *A)
        if k1 * k2 >= 0:
            if s1 < 0 or t1 * s2 >= (s1 ** 2) * t2:
                res.append("Yes")
            else:
                res.append("No")
        else:
            if s1 <= 0 and t1 * s2 <= (s1 ** 2) * t2:
                res.append("Yes")
            else:
                res.append("No")

    print(*res, sep="\n")


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