結果

問題 No.2564 衝突予測
ユーザー nikoro256nikoro256
提出日時 2023-12-08 18:47:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 546 ms / 2,000 ms
コード長 1,113 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,396 KB
最終ジャッジ日時 2023-12-08 18:47:45
合計ジャッジ時間 6,844 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 520 ms
78,012 KB
testcase_04 AC 527 ms
78,020 KB
testcase_05 AC 510 ms
77,688 KB
testcase_06 AC 526 ms
77,636 KB
testcase_07 AC 513 ms
77,760 KB
testcase_08 AC 524 ms
77,888 KB
testcase_09 AC 533 ms
78,396 KB
testcase_10 AC 546 ms
78,396 KB
testcase_11 AC 539 ms
78,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
for _ in range(T):
    x1,y1,d1=map(str,input().split())
    x2,y2,d2=map(str,input().split())
    x1=int(x1)
    x2=int(x2)
    y1=int(y1)
    y2=int(y2)
    if {d1,d2} == {'U','D'}:
        if x1==x2 and ((y1>=y2 and d1=='D') or (y2>=y1 and d1=='U')):
            print('Yes')
        else:
            print('No')
    elif {d1,d2} == {'L','R'}:
        if y1==y2 and ((x1>=x2 and d1=='L') or (x2>=x1 and d1=='R')):
            print('Yes')
        else:
            print('No')
    else:
        if d1=='U' or d1=='D':
            x1,y1,d1,x2,y2,d2=x2,y2,d2,x1,y1,d1
        if d1 =='L':
            if d2=='U' and (x1-x2)>0 and (x1-x2)==(y1-y2):
                print('Yes')
            elif d2=='D' and (x1-x2)>0 and (x1-x2)==(y2-y1):
                print('Yes')
            else:
                print('No')
        elif d1=='R':
            if d2=='U' and (x2-x1)>0 and (x2-x1)==(y1-y2):
                print('Yes')
            elif d2=='D' and (x2-x1)>0 and (x2-x1)==(y2-y1):
                print('Yes')
            else:
                print('No')
        else:
            print('No')
0