ABC010 C - 浮気調査
備忘録
問題
考え方
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array # from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall # from decimal import Decimal # from collections import defaultdict, deque sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: list(map(int, sys.stdin.buffer.readline().split())) fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] iss = lambda: sys.stdin.buffer.readline().decode().rstrip() sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] lcm = lambda x, y: (x * y) // math.gcd(x, y) MOD = 10 ** 9 + 7 INF = float('inf') def calc_dist(x1, y1, x2, y2): return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") TXa, TYa, TXb, TYb, T, V = il() n = ii() xy = [il() for _ in range(n)] for x, y in xy: if calc_dist(TXa, TYa, x, y) + calc_dist(x, y, TXb, TYb) <= T * V: print('YES') exit() else: print('NO') if __name__ == '__main__': main()
考え方
電話前の位置 -> 女の子の家 -> 電話後の位置 の移動距離の合計が
移動可能な距離を下回っている場合には、
家に寄った可能性がある。
計算を間違えないように、全ての女の子の家に対して、
電話前の位置から女の子の家までの距離 + 女の子の家から電話後の位置までの距離 が、
移動可能な距離(T * V
)を上回るか否かを確かめる。