結果

問題 No.2564 衝突予測
ユーザー loop0919loop0919
提出日時 2023-11-14 19:25:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 461 ms / 2,000 ms
コード長 894 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,348 KB
最終ジャッジ日時 2023-11-23 14:02:42
合計ジャッジ時間 5,657 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 456 ms
77,132 KB
testcase_04 AC 442 ms
77,120 KB
testcase_05 AC 440 ms
76,992 KB
testcase_06 AC 453 ms
77,120 KB
testcase_07 AC 453 ms
77,000 KB
testcase_08 AC 444 ms
77,288 KB
testcase_09 AC 461 ms
77,216 KB
testcase_10 AC 459 ms
77,216 KB
testcase_11 AC 459 ms
77,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

rotate = ["R", "U", "L", "D"]

def solve():
    x_1, y_1, d_1 = input().split()
    x_1 = int(x_1); y_1 = int(y_1)
    x_2, y_2, d_2 = input().split()
    x_2 = int(x_2); y_2 = int(y_2)
    
    d_2 = rotate[(rotate.index(d_2) - rotate.index(d_1)) % 4]
    for _ in range(rotate.index(d_1)):
        x_1, y_1 = y_1, -x_1
        x_2, y_2 = y_2, -x_2
    
    if x_1 > x_2:
        print("No")
        return
    
    if d_2 == "R":
        print("No")
        
    elif d_2 == "U":
        if x_2 - x_1 == y_1 - y_2:
            print("Yes")
        else:
            print("No")
            
    elif d_2 == "L":
        if y_1 == y_2:
            print("Yes")
        else:
            print("No")
            
    elif d_2 == "D":
        if x_2 - x_1 == y_2 - y_1:
            print("Yes")
        else:
            print("No")
            


T = int(input())
for _ in range(T):
    solve()
0