結果

問題 No.2564 衝突予測
ユーザー lloyzlloyz
提出日時 2023-12-15 01:13:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 407 ms / 2,000 ms
コード長 1,716 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,124 KB
最終ジャッジ日時 2023-12-15 01:14:02
合計ジャッジ時間 6,269 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 377 ms
77,124 KB
testcase_04 AC 352 ms
77,124 KB
testcase_05 AC 351 ms
77,124 KB
testcase_06 AC 350 ms
77,124 KB
testcase_07 AC 348 ms
77,124 KB
testcase_08 AC 368 ms
77,124 KB
testcase_09 AC 376 ms
76,996 KB
testcase_10 AC 407 ms
76,996 KB
testcase_11 AC 375 ms
76,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    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")
        continue
    if x1 == x2:
        if y1 > y2 and d1 == 'D' and d2 == 'U':
            print("Yes")
        elif y1 < y2 and d1 == 'U' and d2 == 'D':
            print("Yes")
        else:
            print("No")
    elif y1 == y2:
        if x1 > x2 and d1 == 'L' and d2 == 'R':
            print("Yes")
        elif x1 < x2 and d1 == 'R' and d2 == 'L':
            print("Yes")
        else:
            print("No")
    else:
        dd1 = abs(x1 - x2)
        dd2 = abs(y1 - y2)
        if dd1 != dd2:
            print("No")
            continue
        if x1 < x2:
            if y1 < y2:
                if d1 == 'R' and d2 == 'D':
                    print("Yes")
                elif d1 == 'U' and d2 == 'L':
                    print("Yes")
                else:
                    print("No")
            else:
                if d1 == 'R' and d2 == 'U':
                    print("Yes")
                elif d1 == 'D' and d2 == 'L':
                    print("Yes")
                else:
                    print("No")
        else:
            if y1 < y2:
                if d1 == 'L' and d2 == 'D':
                    print("Yes")
                elif d1 == 'U' and d2 == 'R':
                    print("Yes")
                else:
                    print("No")
            else:
                if d1 == 'L' and d2 == 'U':
                    print("Yes")
                elif d1 == 'D' and d2 == 'R':
                    print("Yes")
                else:
                    print("No")
0