結果

問題 No.2564 衝突予測
ユーザー kemunikukemuniku
提出日時 2023-12-02 15:38:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 468 ms / 2,000 ms
コード長 1,404 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,836 KB
最終ジャッジ日時 2023-12-02 15:38:29
合計ジャッジ時間 5,446 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 442 ms
77,332 KB
testcase_04 AC 436 ms
77,628 KB
testcase_05 AC 463 ms
77,636 KB
testcase_06 AC 442 ms
77,572 KB
testcase_07 AC 432 ms
77,560 KB
testcase_08 AC 449 ms
77,572 KB
testcase_09 AC 468 ms
77,552 KB
testcase_10 AC 452 ms
77,836 KB
testcase_11 AC 449 ms
77,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for i in range(T):
    x1,y1,d1 = input().split()
    x2,y2,d2 = input().split()
    x1 = int(x1)
    y1 = int(y1)
    x2 = int(x2)
    y2 = int(y2)
    if d1 == d2:
        print("No")
    elif d1 in "RL"  and d2 in "RL":
        if y1 == y2 and ((x1 < x2 and d1 == "R" and d2 == "L") or (x1 > x2 and d1 == "L" and d2 == "R")):
            print("Yes")
        else:
            print("No")
    elif d1 in "UD" and d2 in "UD":
        if x1 == x2 and((y1 < y2 and d1 == "U" and d2 == "D") or (y1 > y2 and d1 == "D" and d2 == "U")):
            print("Yes")
        else:
            print("No")
    else:
        x2-=x1
        y2-=y1
        x1,y1 = 0,0
        if d1 == "R":
            pass
        if d1 == "L":
            x2 *= -1
        if d1 == "U":
            x2,y2 = y2,x2
            y2 *= -1
            if d2 == "R":
                d2 = "D"
            else:
                d2 = "U"
        if d1 == "D":
            x2,y2 = y2,x2
            x2 *= -1
            if d2 == "L":
                d2 = "D"
            else:
                d2 = "U"
        if (y2 > 0 and d2 == "U") or (y2 < 0 and d2 == "D"):
            print("No")
        elif y2 >= 0:
            if y2 == x2:
                print("Yes")
            else:
                print("No")
        else:
            if (-y2) == x2:
                print("Yes")
            else:
                print("No")
0