結果

問題 No.2564 衝突予測
ユーザー navel_tosnavel_tos
提出日時 2023-12-02 15:04:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 547 ms / 2,000 ms
コード長 849 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,172 KB
最終ジャッジ日時 2023-12-02 15:04:16
合計ジャッジ時間 6,895 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 498 ms
76,888 KB
testcase_04 AC 498 ms
77,824 KB
testcase_05 AC 482 ms
77,656 KB
testcase_06 AC 454 ms
78,172 KB
testcase_07 AC 494 ms
77,796 KB
testcase_08 AC 468 ms
78,100 KB
testcase_09 AC 547 ms
78,056 KB
testcase_10 AC 520 ms
78,052 KB
testcase_11 AC 545 ms
77,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#緑以下H

def move(s):
    if s=='R': return (1,0)
    if s=='L': return (-1,0)
    if s=='U': return (0,1)
    if s=='D': return (0,-1)

for _ in range(int(input())):
    x1,y1,d1 = input().split()
    x2,y2,d2 = input().split()
    x1,y1,x2,y2 = map(int,[x1,y1,x2,y2])
    x1,y1,x2,y2 = x1*2, y1*2, x2*2, y2*2
    hantei = 0

    #x軸・y軸の距離差のうち、半分くらいのものと長い方で衝突判定
    for t in [abs(x1-x2)//2, abs(x1-x2)//2+1, abs(y1-y2)//2, \
              abs(y1-y2)//2+1, abs(x1-x2), abs(y1-y2)]:
        way = move(d1)
        wx,wy = way[0]*t, way[1]*t
        newx1 = x1 + wx
        newy1 = y1 + wy
        way = move(d2)
        wx,wy = way[0]*t, way[1]*t
        newx2 = x2 + wx
        newy2 = y2 + wy
        if newx1 == newx2 and newy1 == newy2: hantei = 1

    print('Yes' if hantei else 'No')
0