結果
問題 | No.2564 衝突予測 |
ユーザー |
![]() |
提出日時 | 2023-12-02 16:42:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 683 ms / 2,000 ms |
コード長 | 1,732 bytes |
コンパイル時間 | 241 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 81,184 KB |
最終ジャッジ日時 | 2024-09-26 20:37:54 |
合計ジャッジ時間 | 7,346 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
#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] = 0elif case[2]=='U':res[2] = 1elif case[2]=='L':res[2] = 2elif case[2]=='D':res[2] = 3return resdef check(case1, case2):x1,y1,d1 = case1x2,y2,d2 = case2#一次元で動くif d1!=d2 and (d1+d2)%2==0:#RLif d1*d2==0 and y1==y2:if x2>x1 and d1 == 0:return Trueelif x2<x1 and d1==2:return Trueelse:return False#UDelif d1*d2>0 and x1==x2:if y2>y1 and d1==1:return Trueelif y2<y1 and d1==3:return Trueelse:return Falseelse:return False#同じ方向elif d1==d2:return False#1が左右に動くif d1%2==0:dx21 = x2- x1#離れていく場合if dx21 >0 and d1==2:return Falseelif dx21 < 0 and d1==0:return Falsedy12 = y1-y2if dy12 > 0 and d2==3:return Falseelif dy12 < 0 and d2==1:return Falseif abs(dy12) == abs(dx21):return True#1が上下に動くelse:#上下に動くdy21 = y2-y1#離れる場合if dy21 > 0 and d1==3:return Falseelif dy21 < 0 and d1 == 1:return Falsedx12 = x1- x2#離れる場合if dx12 >0 and d2==2:return Falseelif dx12 < 0 and d2==0:return Falseif abs(dx12) == abs(dy21):return Truereturn FalseT = 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')