結果

問題 No.2564 衝突予測
ユーザー prd_xxxprd_xxx
提出日時 2023-12-02 15:22:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 554 ms / 2,000 ms
コード長 1,043 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,780 KB
最終ジャッジ日時 2023-12-02 15:22:56
合計ジャッジ時間 6,395 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 523 ms
77,220 KB
testcase_04 AC 551 ms
77,216 KB
testcase_05 AC 519 ms
77,540 KB
testcase_06 AC 554 ms
77,468 KB
testcase_07 AC 485 ms
77,344 KB
testcase_08 AC 493 ms
77,216 KB
testcase_09 AC 506 ms
77,776 KB
testcase_10 AC 544 ms
77,780 KB
testcase_11 AC 503 ms
77,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(x1,y1,d1, x2,y2,d2):
    if d1==d2: return False
    if d1=='R':
        if d2=='L':
            return y1==y2 and x1 < x2
        elif d2=='U':
            return y1 > y2 and x2-x1 == y1-y2
        else:
            return y1 < y2 and x2-x1 == y2-y1
    elif d1=='L':
        if d2=='R':
            return y1==y2 and x1 > x2
        elif d2=='U':
            return y1 > y2 and x2-x1 == y2-y1
        else:
            return y1 < y2 and x2-x1 == y1-y2
    elif d1=='U':
        if d2=='D':
            return x1==x2 and y1 < y2
        elif d2=='R':
            return y1 < y2 and x1-x2 == y2-y1
        else:
            return y1 < y2 and x2-x1 == y2-y1
    else:
        if d2=='U':
            return x1==x2 and y1 > y2
        elif d2=='R':
            return y1 > y2 and x1-x2 == y1-y2
        else:
            return y1 > y2 and x2-x1 == y1-y2

T = int(input())
for _ in range(T):
    x1,y1,d1 = input().split()
    x2,y2,d2 = input().split()
    print('Yes' if solve(int(x1), int(y1), d1, int(x2), int(y2), d2) else 'No')
0