結果

問題 No.2564 衝突予測
ユーザー Yuto_kyopro0731Yuto_kyopro0731
提出日時 2023-12-02 16:42:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 641 ms / 2,000 ms
コード長 1,732 bytes
コンパイル時間 553 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 80,404 KB
最終ジャッジ日時 2023-12-02 16:42:39
合計ジャッジ時間 7,413 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,332 KB
testcase_01 AC 32 ms
53,332 KB
testcase_02 AC 31 ms
53,332 KB
testcase_03 AC 613 ms
80,336 KB
testcase_04 AC 596 ms
80,216 KB
testcase_05 AC 634 ms
80,040 KB
testcase_06 AC 620 ms
80,404 KB
testcase_07 AC 575 ms
80,288 KB
testcase_08 AC 607 ms
79,524 KB
testcase_09 AC 610 ms
80,212 KB
testcase_10 AC 641 ms
80,084 KB
testcase_11 AC 618 ms
80,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#R=0,U=1,L=2,D=3,

def change(case):
    res = [0,0,0]
    res[0] = int(case[0])
    res[1] = int(case[1])
    if case[2]=='R':res[2] = 0
    elif case[2]=='U':res[2] = 1
    elif case[2]=='L':res[2] = 2
    elif case[2]=='D':res[2] = 3
    return res

def check(case1, case2):
    x1,y1,d1 = case1
    x2,y2,d2 = case2
    #一次元で動く
    if d1!=d2 and (d1+d2)%2==0:
        #RL
        if d1*d2==0 and y1==y2:
            if x2>x1 and d1 == 0:return True
            elif x2<x1 and d1==2:return True
            else:return False
        #UD
        elif d1*d2>0 and x1==x2:
            if y2>y1 and d1==1:return True
            elif y2<y1 and d1==3:return True
            else:return False
        else:return False
    #同じ方向
    elif d1==d2:return False
    
    #1が左右に動く
    if d1%2==0:
        dx21 = x2- x1
        #離れていく場合
        if dx21 >0 and d1==2:return False
        elif dx21 < 0 and d1==0:return False
        dy12 = y1-y2
        if dy12 > 0 and d2==3:return False
        elif dy12 < 0 and d2==1:return False
        
        if abs(dy12) == abs(dx21):return True
    #1が上下に動く
    else:
        #上下に動く
        dy21 = y2-y1
        #離れる場合
        if dy21 > 0 and d1==3:return False
        elif dy21 < 0 and d1 == 1:return False 
        dx12 = x1- x2
        #離れる場合
        if dx12 >0 and d2==2:return False
        elif dx12 < 0 and d2==0:return False
        
        if abs(dx12) == abs(dy21):return True

    return False
        
T = int(input())
for i in range(T):
    case1 = change(list(input().split()))
    case2 = change(list(input().split()))
    
    ans = check(case1, case2)
    print('Yes' if ans else 'No')
    
0