結果

問題 No.2564 衝突予測
ユーザー nzm_ortnzm_ort
提出日時 2023-12-02 16:55:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 503 ms / 2,000 ms
コード長 1,868 bytes
コンパイル時間 605 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,140 KB
最終ジャッジ日時 2023-12-02 16:55:55
合計ジャッジ時間 6,114 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,460 KB
testcase_01 AC 33 ms
53,460 KB
testcase_02 AC 33 ms
53,460 KB
testcase_03 AC 494 ms
77,760 KB
testcase_04 AC 471 ms
77,936 KB
testcase_05 AC 496 ms
77,956 KB
testcase_06 AC 466 ms
78,032 KB
testcase_07 AC 454 ms
77,976 KB
testcase_08 AC 484 ms
77,880 KB
testcase_09 AC 489 ms
77,752 KB
testcase_10 AC 503 ms
77,884 KB
testcase_11 AC 484 ms
78,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
for _ in range(t):
    x1, y1, d1 = map(str, input().split())
    x2, y2, d2 = map(str, input().split())
    x1, y1 = int(x1), int(y1)
    x2, y2 = int(x2), int(y2)
    
    if (d1=="U" or d1=="D") and (d2=="U" or d2=="D"):
        if x1!=x2: print('No'); continue
    if (d1=="L" or d1=="R") and (d2=="L" or d2=="R"):
        if y1!=y2: print('No'); continue
    
    if x1==x2:
        if (d1=="U" and d2=="D"):
            if y1<y2: print('Yes'); continue
            else: print('No'); continue
        elif (d1=="D" and d2=="U"):
            if y1>y2: print('Yes'); continue
            else: print('No'); continue
        else: print('No'); continue
    elif y1==y2:
        if (d1=="L" and d2=="R"):
            if x1>x2: print('Yes'); continue
            else: print('No'); continue
        elif (d1=="R" and d2=="L"):
            if x1<x2: print('Yes'); continue
            else: print('No'); continue
        else: print('No'); continue
    else:
        f = True
        if d1=="U":
            if y1>y2: print('No'); f=False
            else: t1=y2-y1
        elif d1=="D":
            if y1<y2: print('No'); f=False
            else: t1=y1-y2
        elif d1=="L":
            if x1<x2: print('No'); f=False
            else: t1=x1-x2
        else:
            if x1>x2: print('No'); f=False
            else: t1=x2-x1
        
        if f:
            if d2=="U":
                if y1<y2: print('No'); f=False
                else: t2=y1-y2
            elif d2=="D":
                if y1>y2: print('No'); f=False
                else: t2=y2-y1
            elif d2=="L":
                if x1>x2: print('No'); f=False
                else: t2=x2-x1
            else:
                if x1<x2: print('No'); f=False
                else: t2=x1-x2
        
        if f:
            if t1==t2: print('Yes')
            else: print('No')
0