結果

問題 No.323 yuki国
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-04 03:15:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,156 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 198,684 KB
最終ジャッジ日時 2024-04-21 22:33:28
合計ジャッジ時間 30,271 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,272 KB
testcase_01 AC 57 ms
65,152 KB
testcase_02 AC 80 ms
76,928 KB
testcase_03 AC 112 ms
80,384 KB
testcase_04 AC 73 ms
72,704 KB
testcase_05 AC 88 ms
77,952 KB
testcase_06 WA -
testcase_07 AC 44 ms
55,168 KB
testcase_08 AC 1,649 ms
194,432 KB
testcase_09 AC 1,604 ms
194,560 KB
testcase_10 AC 40 ms
53,892 KB
testcase_11 AC 57 ms
65,152 KB
testcase_12 AC 55 ms
64,768 KB
testcase_13 AC 1,607 ms
194,816 KB
testcase_14 AC 1,640 ms
194,688 KB
testcase_15 AC 586 ms
163,436 KB
testcase_16 AC 1,505 ms
197,876 KB
testcase_17 AC 1,791 ms
194,852 KB
testcase_18 AC 407 ms
112,020 KB
testcase_19 AC 949 ms
149,448 KB
testcase_20 AC 1,916 ms
196,272 KB
testcase_21 AC 1,837 ms
198,684 KB
testcase_22 AC 1,893 ms
198,208 KB
testcase_23 AC 1,964 ms
196,316 KB
testcase_24 AC 613 ms
162,416 KB
testcase_25 AC 615 ms
162,684 KB
testcase_26 AC 1,794 ms
195,200 KB
testcase_27 AC 1,840 ms
195,048 KB
testcase_28 AC 1,898 ms
194,760 KB
testcase_29 AC 1,707 ms
194,504 KB
testcase_30 AC 41 ms
54,784 KB
testcase_31 AC 64 ms
68,352 KB
testcase_32 AC 71 ms
72,320 KB
testcase_33 AC 61 ms
67,840 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 76 ms
73,856 KB
testcase_37 AC 69 ms
71,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
DX = (-1, 0, 1, 0, -1, -1, 1, 1)
DY = (0, 1, 0, -1, -1, 1, -1, 1)
DX = DX[:4]
DY = DY[:4]

H, W = map(int, input().split())
A, sx, sy = map(int, input().split())
B, gx, gy = map(int, input().split())
sx += 1
sy += 1
gx += 1
gy += 1
G = [[0] * (W + 2) for _ in range(H + 2)]
for i in range(1, H + 1):
    for j, x in enumerate(input().rstrip(), 1):
        if x == "*":
            G[i][j] = 1
        else:
            G[i][j] = -1

U = 1000 + 50 * 50
dist = [[[-1] * (U + 1) for _ in range(W + 2)] for _ in range(H + 2)]
dist[sx][sy][A] = 0
que = deque([(sx, sy, A)])
while que:
    x, y, a = que.popleft()
    d = dist[x][y][a]
    for dx, dy in zip(DX, DY):
        nx = x + dx
        ny = y + dy
        if G[nx][ny] == 1 and a < U and dist[nx][ny][a + 1] == -1:
            dist[nx][ny][a + 1] = d + 1
            que.append((nx, ny, a + 1))
        if G[nx][ny] == -1 and a and dist[nx][ny][a - 1] == -1:
            dist[nx][ny][a - 1] = d + 1
            que.append((nx, ny, a - 1))

if dist[gx][gy][B] == -1:
    print("No")
else:
    print("Yes")
0