結果

問題 No.2564 衝突予測
ユーザー oginoshikibuoginoshikibu
提出日時 2023-12-02 15:36:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 432 ms / 2,000 ms
コード長 1,455 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,252 KB
最終ジャッジ日時 2023-12-02 15:36:48
合計ジャッジ時間 5,118 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 32 ms
53,460 KB
testcase_02 AC 33 ms
53,460 KB
testcase_03 AC 390 ms
77,124 KB
testcase_04 AC 396 ms
77,252 KB
testcase_05 AC 419 ms
77,124 KB
testcase_06 AC 406 ms
77,124 KB
testcase_07 AC 398 ms
77,124 KB
testcase_08 AC 413 ms
77,124 KB
testcase_09 AC 410 ms
76,996 KB
testcase_10 AC 407 ms
76,996 KB
testcase_11 AC 432 ms
76,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    x1,y1,d1=input().split()
    x2,y2,d2=input().split()
    x1,y1,x2,y2=int(x1),int(y1),int(x2),int(y2)

    if d1 in {"L","R"} and d2 in {"L","R"}:
        if y1!=y2 or d1==d2:
            print("No")
        elif x1<x2 and d1=="R" and d2=="L":
            print("Yes")
        elif x1>x2 and d1=="L" and d2=="R":
            print("Yes")
        else:
            print("No")
        continue
    elif d1 in {"U","D"} and d2 in {"U","D"}:
        if x1!=x2 or d1==d2:
            print("No")
        elif y1<y2 and d1=="U" and d2=="D":
            print("Yes")
        elif y1>y2 and d1=="D" and d2=="U":
            print("Yes")
        else:
            print("No")
        continue

    if d1 in {"U","D"}:
        x1,y1,d1,x2,y2,d2=x2,y2,d2,x1,y1,d1

    # 距離が同じ
    if abs(x1-x2)!=abs(y1-y2):
        print("No")
        continue

    # 向きが正しい
    if d1=="R" and d2=="U":
        if x1<x2 and y1>y2:
            print("Yes")
        else:
            print("No")
        continue
    elif d1=="R" and d2=="D":
        if x1<x2 and y1<y2:
            print("Yes")
        else:
            print("No")
        continue
    elif d1=="L" and d2=="U":
        if x1>x2 and y1>y2:
            print("Yes")
        else:
            print("No")
        continue
    elif d1=="L" and d2=="D":
        if x1>x2 and y1<y2:
            print("Yes")
        else:
            print("No")
        continue
0