結果

問題 No.2564 衝突予測
ユーザー sA_3sA_3
提出日時 2023-12-02 16:02:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 438 ms / 2,000 ms
コード長 1,769 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,552 KB
最終ジャッジ日時 2023-12-02 16:02:40
合計ジャッジ時間 5,347 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 32 ms
53,460 KB
testcase_03 AC 392 ms
77,124 KB
testcase_04 AC 438 ms
77,304 KB
testcase_05 AC 407 ms
77,124 KB
testcase_06 AC 405 ms
77,124 KB
testcase_07 AC 429 ms
77,532 KB
testcase_08 AC 399 ms
77,300 KB
testcase_09 AC 426 ms
77,548 KB
testcase_10 AC 428 ms
77,552 KB
testcase_11 AC 418 ms
77,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    x1,y1,d1 = input().split()
    x2,y2,d2 = input().split()
    x1,x2,y1,y2 = int(x1),int(x2),int(y1),int(y2)
    ans = 'No'
    if d1 == d2:
        ans = 'No'
    # 向かい合う
    elif x1 == x2:
        if (d1 == 'U' and d2 == 'D') and y1 < y2:
            ans = 'Yes'
        elif (d1 == 'D' and d2 == 'U') and y1 > y2:
            ans = 'Yes'
        else:
            ans = 'No'
    elif y1 == y2:
        if (d1 == 'L' and d2 == 'R') and x1 > x2:
            ans = 'Yes'
        elif (d1 == 'R' and d2 == 'L') and x1 < x2:
            ans = 'Yes'
        else:
            ans = 'No'
    
    else: # 向かい合わない UL UR DL DR
        if (d1 == 'U' and d2 == 'L') or (d1 == 'L' and d2 == 'U'):
            if d1 == 'L':
                x1,y1,x2,y2 = x2,y2,x1,y1
            
            if x2-x1 == y2-y1 > 0:
                ans = 'Yes'
            else:
                ans = 'No'
        
        elif (d1 == 'U' and d2 == 'R') or (d1 == 'R' and d2 == 'U'):
            if d1 == 'R':
                x1,y1,x2,y2 = x2,y2,x1,y1
            
            if x1-x2 == y2-y1 > 0:
                ans = 'Yes'
            else:
                ans = 'No'
        
        elif (d1 == 'D' and d2 == 'L') or (d1 == 'L' and d2 == 'D'):
            if d1 == 'L':
                x1,y1,x2,y2 = x2,y2,x1,y1
            
            if x2-x1 == y1-y2 > 0:
                ans = 'Yes'
            else:
                ans = 'No'
            
        elif (d1 == 'D' and d2 == 'R') or (d1 == 'R' and d2 == 'D'):
            if d1 == 'R':
                x1,y1,x2,y2 = x2,y2,x1,y1
            
            if x1-x2 == y1-y2 > 0:
                ans = 'Yes'
            else:
                ans = 'No'
        
    print(ans)
0