結果

問題 No.2602 Real Collider
ユーザー cleanttedcleantted
提出日時 2023-11-28 20:21:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 418 ms / 2,000 ms
コード長 2,445 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 81,956 KB
実行使用メモリ 121,424 KB
最終ジャッジ日時 2023-11-28 20:22:08
合計ジャッジ時間 32,577 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
89,552 KB
testcase_01 AC 170 ms
89,552 KB
testcase_02 AC 170 ms
89,552 KB
testcase_03 AC 172 ms
89,552 KB
testcase_04 AC 181 ms
89,552 KB
testcase_05 AC 170 ms
89,552 KB
testcase_06 AC 172 ms
89,552 KB
testcase_07 AC 171 ms
89,552 KB
testcase_08 AC 173 ms
89,552 KB
testcase_09 AC 175 ms
89,552 KB
testcase_10 AC 418 ms
121,424 KB
testcase_11 AC 285 ms
105,552 KB
testcase_12 AC 311 ms
108,880 KB
testcase_13 AC 269 ms
98,256 KB
testcase_14 AC 320 ms
110,032 KB
testcase_15 AC 270 ms
101,072 KB
testcase_16 AC 296 ms
105,040 KB
testcase_17 AC 328 ms
108,368 KB
testcase_18 AC 271 ms
102,736 KB
testcase_19 AC 304 ms
105,936 KB
testcase_20 AC 319 ms
110,928 KB
testcase_21 AC 299 ms
103,248 KB
testcase_22 AC 309 ms
105,808 KB
testcase_23 AC 276 ms
99,280 KB
testcase_24 AC 318 ms
104,912 KB
testcase_25 AC 277 ms
104,656 KB
testcase_26 AC 269 ms
101,328 KB
testcase_27 AC 302 ms
103,632 KB
testcase_28 AC 331 ms
107,728 KB
testcase_29 AC 294 ms
105,680 KB
testcase_30 AC 309 ms
106,576 KB
testcase_31 AC 302 ms
105,680 KB
testcase_32 AC 287 ms
104,400 KB
testcase_33 AC 302 ms
104,144 KB
testcase_34 AC 300 ms
106,320 KB
testcase_35 AC 294 ms
100,432 KB
testcase_36 AC 268 ms
100,432 KB
testcase_37 AC 312 ms
108,368 KB
testcase_38 AC 306 ms
106,064 KB
testcase_39 AC 341 ms
109,008 KB
testcase_40 AC 257 ms
97,488 KB
testcase_41 AC 310 ms
109,008 KB
testcase_42 AC 288 ms
102,608 KB
testcase_43 AC 319 ms
104,912 KB
testcase_44 AC 319 ms
109,904 KB
testcase_45 AC 285 ms
102,224 KB
testcase_46 AC 303 ms
100,560 KB
testcase_47 AC 300 ms
105,424 KB
testcase_48 AC 288 ms
104,016 KB
testcase_49 AC 272 ms
100,688 KB
testcase_50 AC 277 ms
98,512 KB
testcase_51 AC 262 ms
99,664 KB
testcase_52 AC 244 ms
96,720 KB
testcase_53 AC 313 ms
106,064 KB
testcase_54 AC 297 ms
101,712 KB
testcase_55 AC 289 ms
105,040 KB
testcase_56 AC 288 ms
104,784 KB
testcase_57 AC 275 ms
101,584 KB
testcase_58 AC 254 ms
95,184 KB
testcase_59 AC 294 ms
105,040 KB
testcase_60 AC 287 ms
104,784 KB
testcase_61 AC 279 ms
101,456 KB
testcase_62 AC 315 ms
105,552 KB
testcase_63 AC 307 ms
106,832 KB
testcase_64 AC 311 ms
108,624 KB
testcase_65 AC 270 ms
101,456 KB
testcase_66 AC 325 ms
108,752 KB
testcase_67 AC 264 ms
98,896 KB
testcase_68 AC 294 ms
99,536 KB
testcase_69 AC 266 ms
96,976 KB
testcase_70 AC 273 ms
99,408 KB
testcase_71 AC 283 ms
101,200 KB
testcase_72 AC 294 ms
104,528 KB
testcase_73 AC 280 ms
103,504 KB
testcase_74 AC 320 ms
105,936 KB
testcase_75 AC 304 ms
106,960 KB
testcase_76 AC 288 ms
102,480 KB
testcase_77 AC 298 ms
104,528 KB
testcase_78 AC 344 ms
109,776 KB
testcase_79 AC 307 ms
106,320 KB
testcase_80 AC 308 ms
107,728 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