結果

問題 No.2564 衝突予測
ユーザー torippytorippy
提出日時 2023-12-02 15:40:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 592 ms / 2,000 ms
コード長 1,527 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 79,356 KB
最終ジャッジ日時 2023-12-02 15:40:18
合計ジャッジ時間 6,801 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 33 ms
53,460 KB
testcase_02 AC 34 ms
53,460 KB
testcase_03 AC 546 ms
78,928 KB
testcase_04 AC 561 ms
78,568 KB
testcase_05 AC 539 ms
78,568 KB
testcase_06 AC 564 ms
79,024 KB
testcase_07 AC 552 ms
79,344 KB
testcase_08 AC 574 ms
78,968 KB
testcase_09 AC 557 ms
79,100 KB
testcase_10 AC 592 ms
79,260 KB
testcase_11 AC 560 ms
79,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

YES = "Yes"
NO = "No"


#d1はR固定
def is_ok(x1, x2, y1, y2, d2):
    if x1 < x2:
        if y1 < y2:
            if d2 == "D":
                if x2-x1 == y2-y1:
                    print(YES)
                else:
                    print(NO)
            else:
                print(NO)
        elif y1 == y2:
            if d2 == "L":
                print(YES)
            else:
                print(NO)
        else:
            if d2 == "U":
                if x2-x1 == y1-y2:
                    print(YES)
                else:
                    print(NO)
            else:
                print(NO)
    else:
        print(NO)

T = int(input())

for _ 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 == "L":
        x1 *= -1
        x2 *= -1
        d1 = "R"
        if d2 == "L":
            d2 = "R"
        elif d2 == "R":
            d2 = "L"
    elif d1 == "U":
        x1, y1 = y1, -x1
        x2, y2 = y2, -x2
        d1 = "R"
        if d2 == "L":
            d2 = "U"
        elif d2 == "R":
            d2 = "D"
        elif d2 == "U":
            d2 = "R"
        else:
            d2 = "L"
    elif d1 == "D":
        x1, y1 = -y1, x1
        x2, y2 = -y2, x2
        d1 = "R"
        if d2 == "L":
            d2 = "D"
        elif d2 == "R":
            d2 = "U"
        elif d2 == "U":
            d2 = "L"
        else:
            d2 = "R"
    
    is_ok(x1, x2, y1, y2, d2)

        
0