結果

問題 No.2564 衝突予測
ユーザー hatonobuhatonobu
提出日時 2023-12-02 15:29:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,802 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 83,608 KB
最終ジャッジ日時 2023-12-02 15:29:39
合計ジャッジ時間 5,746 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,732 KB
testcase_01 AC 39 ms
55,732 KB
testcase_02 AC 39 ms
55,732 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque,defaultdict
import itertools
import heapq
import bisect
import math

#sys.setrecursionlimit(10 ** 9)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
ml = lambda: map(str, input().split())
li = lambda: list(mi())
li_st = lambda: list(map(str, input().split()))
lli = lambda n: [li() for _ in range(n)]
mod = 998244353

T = ii()
def check(x,y,d,xx,yy):
    if d == "U":
        if yy >= y:
            y += yy - y
        else:
            return x,y,False
    elif d == "D":
        if y >= yy:
            y -= y - yy
        else:
            return x,y,False
    elif d == "L":
        if x >= xx:
            x -= x - xx
        else:
            return x,y,False
    else:
        if xx >= x:
            x += xx - x
        else:
            return x,y,False
        
    return x,y,True


for i in range(T):
    x1,y1,d1 = ml()
    x2,y2,d2 = ml()
    x1,y1 = int(x1),int(y1)
    x2,y2 = int(x2),int(y2)
    ans = set()
    x,y,flag1 = check(x1,y1,d1,x2,y2)
    xx,yy,flag2 = check(x2,y2,d2,x1,y1)
    if flag1 and flag2:
        ans.add((x,y))
        ans.add((xx,yy))
        if len(ans) == 1:
            print("Yes")
        else:
            n = set()
            n.add(d1)
            n.add(d2)
            if len(n) == 1:
                print("No")
            else:
                if n == {"U","D"}:
                    if x == xx:
                        print("Yes")
                    else:
                        print("No")
                elif n == {"R","L"}:
                    if y == yy:
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
    else:
        print("No")
0