結果

問題 No.2564 衝突予測
ユーザー KoiKoi
提出日時 2023-12-02 15:31:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 1,022 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 81,572 KB
最終ジャッジ日時 2023-12-02 15:31:51
合計ジャッジ時間 3,499 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 222 ms
81,108 KB
testcase_04 AC 242 ms
80,820 KB
testcase_05 AC 226 ms
81,108 KB
testcase_06 AC 222 ms
80,860 KB
testcase_07 AC 224 ms
81,572 KB
testcase_08 AC 218 ms
81,564 KB
testcase_09 AC 250 ms
81,324 KB
testcase_10 AC 221 ms
81,324 KB
testcase_11 AC 219 ms
81,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
answers=[]
dx=[1,0,-1,0]
dy=[0,1,0,-1]
dir=list("RULD")
def is_collision(x1,y1,d1,x2,y2,d2):
    r1=dir.index(d1)
    r2=dir.index(d2)
    if(r1==r2):
        return False
    if(dx[r1]==dx[r2]):
        if(x1!=x2):
            return False
        if((dy[r1]-dy[r2])*(y1-y2)<0):
            return True
        else:
            return False
    if(dy[r1]==dy[r2]):
        if(y1!=y2):
            return False
        if((dx[r1]-dx[r2])*(x1-x2)<0):
            return True
        else:
            return False
    if(dx[r1]==0 and dy[r2]==0):
        x1,y1,r1,x2,y2,r2=x2,y2,r2,x1,y1,r1
    t1=((x2-x1)//dx[r1])
    t2=((y1-y2)//dy[r2])
    if(t1>0 and t2>0 and t1==t2):
        return True
    else:
        return False
for _ in range(T):
    x1,y1,d1=input().split()
    x2,y2,d2=input().split()
    x1=int(x1)
    x2=int(x2)
    y1=int(y1)
    y2=int(y2)
    if(is_collision(x1,y1,d1,x2,y2,d2)):
        answers.append("Yes")
    else:
        answers.append("No")
for ans in answers:
    print(ans)
0