結果

問題 No.2564 衝突予測
ユーザー 21kazu1321kazu13
提出日時 2023-12-04 14:49:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 1,887 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 79,768 KB
最終ジャッジ日時 2023-12-04 14:49:11
合計ジャッジ時間 4,076 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
65,796 KB
testcase_01 AC 55 ms
65,792 KB
testcase_02 AC 55 ms
65,796 KB
testcase_03 AC 211 ms
79,000 KB
testcase_04 AC 232 ms
79,000 KB
testcase_05 AC 211 ms
79,128 KB
testcase_06 AC 208 ms
78,872 KB
testcase_07 AC 213 ms
79,000 KB
testcase_08 AC 211 ms
78,744 KB
testcase_09 AC 279 ms
79,512 KB
testcase_10 AC 252 ms
79,512 KB
testcase_11 AC 252 ms
79,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
from bisect import bisect_left, bisect_right, insort_left, insort_right  # type: ignore
from collections import Counter, defaultdict, deque  # type: ignore
from math import gcd, sqrt, ceil, factorial  # type: ignore
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, merge  # type: ignore
from itertools import accumulate, combinations, permutations, product  # type: ignore
from string import ascii_lowercase, ascii_uppercase # type: ignore

def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode("utf-8").split()
def S(): return sys.stdin.buffer.readline().rstrip().decode("utf-8")
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def SRL(n): return [list(S()) for _ in range(n)]


def solve(x,y,d1,z,w,d2):
    # x==z and y==wは制約からなし
    if x==z:
        # x軸同じ場合
        if y>w:
            y,w=w,y
            d1,d2=d2,d1
        # y<wである
        return True if d1=='U' and d2=='D' else False
    elif y==w:
        # y軸同じ場合
        if x>z:
            x,z = z,x
            d1,d2=d2,d1
        return True if d1=='R' and d2=='L' else False
    else:
        if x>z:
            x,y,d1,z,w,d2 = z,w,d2,x,y,d1
        # x<zである
        if d1=='R':
            if (d2=='U' and y-w==z-x) or (d2=='D' and w-y==z-x):
                return True
        elif d2=='L':
            if (d1=='U' and w-y==z-x) or (d1=='D' and y-w==z-x):
                return True
    return False

T = I()
for _ in range(T):
    x,y,d1 = LS()
    x,y = int(x),int(y)
    z,w,d2 = LS()
    z,w = int(z),int(w)
    print('Yes' if solve(x,y,d1,z,w,d2) else 'No')
0