結果

問題 No.2564 衝突予測
ユーザー u_kunu_kun
提出日時 2023-12-02 16:54:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 667 ms / 2,000 ms
コード長 2,351 bytes
コンパイル時間 461 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 79,688 KB
最終ジャッジ日時 2023-12-02 16:54:13
合計ジャッジ時間 7,440 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,460 KB
testcase_01 AC 39 ms
53,460 KB
testcase_02 AC 40 ms
53,460 KB
testcase_03 AC 600 ms
78,732 KB
testcase_04 AC 624 ms
78,840 KB
testcase_05 AC 606 ms
78,320 KB
testcase_06 AC 629 ms
78,984 KB
testcase_07 AC 599 ms
78,204 KB
testcase_08 AC 632 ms
78,572 KB
testcase_09 AC 637 ms
79,688 KB
testcase_10 AC 667 ms
79,436 KB
testcase_11 AC 637 ms
79,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def manh_check(x1, y1, x2, y2):
    if abs(x1 - x2) == abs(y1 - y2):
        return True
    else:
        return False

def direction(x1, y1, x2, y2):
    # (x1, y1)は(x2, y2)よりもなんなのか?
    
    if x1 < x2 and y1 > y2:
        return "hidariue"
    
    elif x1 < x2 and y1 < y2:
        return "hidarisita"
        
    elif x1 > x2 and y1> y2:
        return "migiue"
    
    elif x1 > x2 and y1 < y2:
        return "migisita"
    
    else:
        return "None"

T = int(input())

for _ in range(T):
    x1, y1, D1 = input().split()
    x2, y2, D2 = input().split()
    
    x1 = int(x1)
    x2 = int(x2)
    y1 = int(y1)
    y2 = int(y2)
    
    if D1 == D2:
        print("No")
        continue

    Flg = False
    
    if D1 == "U" and D2 == "R":
        if direction(x2, y2, x1, y1) == "hidariue" and manh_check(x1, y1, x2, y2):
            Flg = True

    elif D1 == "R" and D2 == "U":
        if direction(x2, y2, x1, y1) == "migisita" and manh_check(x1, y1, x2, y2):
            Flg = True




    elif D1 == "U" and D2 == "L":
        if direction(x2, y2, x1, y1) == "migiue" and manh_check(x1, y1, x2, y2):
            Flg = True

    elif D1 == "L" and D2 == "U":
        if direction(x2, y2, x1, y1) == "hidarisita" and manh_check(x1, y1, x2, y2):
            Flg = True







    elif D1 == "U" and D2 == "D":
        if x1 == x2 and y2 > y1:
            Flg = True
    elif D1 == "D" and D2 == "U":
        if x1 == x2 and y2 < y1:
            Flg = True


    elif D1 == "D" and D2 == "R":
        if direction(x2, y2, x1, y1) == "hidarisita" and manh_check(x1, y1, x2, y2):
            Flg = True

    elif D1 == "R" and D2 == "D":
        if direction(x2, y2, x1, y1) == "migiue" and manh_check(x1, y1, x2, y2):
            Flg = True




    
    elif D1 == "D" and D2 == "L":
        if direction(x2, y2, x1, y1) == "migisita" and manh_check(x1, y1, x2, y2):
            Flg = True

    elif D1 == "L" and D2 == "D":
        if direction(x2, y2, x1, y1) == "hidariue" and manh_check(x1, y1, x2, y2):
            Flg = True
            


    elif D1 == "R" and D2 == "L":
        if y1 == y2 and x1 < x2:
            Flg = True

    elif D1 == "L" and D2 == "R":
        if y1 == y2 and x1 > x2:
            Flg = True
    
    
    if Flg:
        print("Yes")
        
    else:
        print("No")
    
0