結果

問題 No.2564 衝突予測
ユーザー mymelochanmymelochan
提出日時 2023-12-02 15:46:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 452 ms / 2,000 ms
コード長 2,046 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,908 KB
最終ジャッジ日時 2023-12-02 15:46:33
合計ジャッジ時間 5,425 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,720 KB
testcase_01 AC 42 ms
55,720 KB
testcase_02 AC 42 ms
55,720 KB
testcase_03 AC 438 ms
77,780 KB
testcase_04 AC 408 ms
77,652 KB
testcase_05 AC 438 ms
77,780 KB
testcase_06 AC 413 ms
77,652 KB
testcase_07 AC 434 ms
77,780 KB
testcase_08 AC 410 ms
77,652 KB
testcase_09 AC 423 ms
77,908 KB
testcase_10 AC 452 ms
77,908 KB
testcase_11 AC 426 ms
77,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#############################################################

import sys
sys.setrecursionlimit(10**7)

from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations
from math import sin,cos
#from math import isqrt #DO NOT USE PyPy

ipt = sys.stdin.readline
iin = lambda :int(ipt())
lmin = lambda :list(map(int,ipt().split()))

#############################################################

direc = {"U":0,"D":2,"R":1,"L":3}

for _ in range(iin()):
    i1 = input().split()
    i2 = input().split()
    x1,y1,d1 = int(i1[0]),int(i1[1]),direc[i1[2]]
    x2,y2,d2 = int(i2[0]),int(i2[1]),direc[i2[2]]

    if d1 == d2:
        print("No")
        continue

    if d1%2 == 0 and d2%2 == 0:
        if x1 == x2:
            if d1 == 0:
                if y1 < y2:
                    print("Yes")
                else:
                    print("No")
            else:
                if y1 > y2:
                    print("Yes")
                else:
                    print("No")
        else:
            print("No")
    
    elif d1%2 == 1 and d2%2 == 1:
        if y1 == y2:
            if d1 == 1:
                if x1 < x2:
                    print("Yes")
                else:
                    print("No")
            else:
                if x1 > x2:
                    print("Yes")
                else:
                    print("No")
        else:
            print("No")
    
    else:
        dx = x1-x2
        dy = y1-y2
        if dx == dy:
            if x1 < x2:
                d1,d2 = d2,d1

            if (d1 == 2 and d2 == 1) or (d1 == 3 and d2 == 0):
                print("Yes")
            else:
                print("No")

        elif dx == -dy:
            if x1 < x2:
                d1,d2 = d2,d1
            
            if (d1 == 0 and d2 == 1) or (d1 == 3 and d2 == 2):
                print("Yes")
            else:
                print("No")
        else:
            print("No")
0