結果

問題 No.2564 衝突予測
ユーザー K5h1n0K5h1n0
提出日時 2023-12-02 16:58:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,645 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 128,380 KB
最終ジャッジ日時 2023-12-02 16:58:32
合計ジャッジ時間 4,734 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,460 KB
testcase_01 AC 40 ms
53,460 KB
testcase_02 AC 41 ms
53,460 KB
testcase_03 AC 353 ms
128,176 KB
testcase_04 AC 354 ms
128,172 KB
testcase_05 AC 357 ms
128,172 KB
testcase_06 AC 356 ms
128,180 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
l = []
v = {"R":"L","L":"R","U":"D","D":"U"}
for _ in range(t):
    tmp = []
    for i in range(2):
        x,y,d = input().split()
        tmp.append((int(x),int(y),d))
    l.append(tmp)
ans = []
for i in l:
    now1x = i[0][0]
    now1y = i[0][1]
    now2x = i[1][0]
    now2y = i[1][1]
    now1d = i[0][2]
    now2d = i[1][2]
    if v[i[0][2]] == i[1][2]: # ぶつかる方向
        if now1x == now2x:
            if now2y < now1y:
                now1y,now2y = now2y,now1y
                now1d,now2d = now2d,now1d
            if now1y <= now2y and now1d == "U":
                ans.append("Yes")
            else:
                ans.append("No")
            continue
        elif now1y == now2y:
            if now2x < now1x:
                now1x,now2x = now2x,now1x
                now1d,now2d = now2d,now1d
            if now1x <= now2x and now1d == "R":
                ans.append("Yes")
            else:
                ans.append("No")
            continue
        else:
            ans.append("No")
    else: # ぶつかる方向でないなら
        dist1 = abs(now1x-now2x)
        dist2 = abs(now1y-now2y)
        if v[i[0][2]] != i[1][2] and dist1 == dist2:
            if now1d == "R" and now1x <= now2x:
                ans.append("Yes")
            elif now1d == "L" and now2x <= now1x:
                ans.append("Yes")
            elif now1d == "U" and now1y <= now2y:
                ans.append("Yes")
            elif now1d == "D" and now2y <= now1y:
                ans.append("Yes")
            else:
                ans.append("No")
        else:
            ans.append("No")
print(*ans,sep="\n")
0