結果

問題 No.2564 衝突予測
ユーザー flippergo
提出日時 2025-02-14 13:34:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 545 ms / 2,000 ms
コード長 867 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 82,840 KB
実行使用メモリ 78,468 KB
最終ジャッジ日時 2025-02-14 13:34:37
合計ジャッジ時間 7,838 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    x1,y1,d1 = input().split()
    x2,y2,d2 = input().split()
    x1,y1,x2,y2 = map(int,[x1,y1,x2,y2])
    if x1==x2:
        if y1>y2 and d1=="D" and d2=="U":
            print("Yes")
        elif y1<y2 and d1=="U" and d2=="D":
            print("Yes")
        else:
            print("No")
    else:
        if x1>x2:
            x1,x2 = x2,x1
            y1,y2 = y2,y1
            d1,d2 = d2,d1
        if y1==y2:
            if d1=="R" and d2=="L":
                print("Yes")
            else:
                print("No")
        else:
            if y1>y2 and ((d1=="D" and d2=="L") or (d1=="R" and d2=="U")) and x2-x1==y1-y2:
                print("Yes")
            elif y1<y2 and ((d1=="U" and d2=="L") or (d1=="R" and d2=="D")) and x2-x1==y2-y1:
                print("Yes")
            else:
                print("No")
0