結果

問題 No.323 yuki国
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-04 03:12:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,152 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 202,832 KB
最終ジャッジ日時 2024-04-21 22:31:59
合計ジャッジ時間 33,734 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
54,400 KB
testcase_01 AC 65 ms
68,736 KB
testcase_02 AC 42 ms
55,296 KB
testcase_03 AC 120 ms
81,024 KB
testcase_04 AC 81 ms
77,184 KB
testcase_05 AC 87 ms
77,184 KB
testcase_06 WA -
testcase_07 AC 42 ms
55,552 KB
testcase_08 AC 1,736 ms
198,016 KB
testcase_09 AC 1,813 ms
197,956 KB
testcase_10 AC 42 ms
54,044 KB
testcase_11 AC 60 ms
68,864 KB
testcase_12 AC 57 ms
65,792 KB
testcase_13 AC 1,900 ms
199,168 KB
testcase_14 AC 1,883 ms
199,196 KB
testcase_15 WA -
testcase_16 AC 1,881 ms
202,224 KB
testcase_17 AC 2,063 ms
199,404 KB
testcase_18 AC 454 ms
113,936 KB
testcase_19 AC 1,109 ms
152,080 KB
testcase_20 AC 2,010 ms
200,136 KB
testcase_21 AC 1,961 ms
202,832 KB
testcase_22 AC 2,069 ms
201,920 KB
testcase_23 AC 2,062 ms
200,532 KB
testcase_24 AC 671 ms
163,720 KB
testcase_25 AC 639 ms
163,756 KB
testcase_26 AC 1,794 ms
199,340 KB
testcase_27 AC 1,856 ms
199,472 KB
testcase_28 AC 2,024 ms
199,044 KB
testcase_29 AC 2,000 ms
199,004 KB
testcase_30 AC 42 ms
54,392 KB
testcase_31 AC 75 ms
76,928 KB
testcase_32 AC 77 ms
76,992 KB
testcase_33 AC 71 ms
76,416 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 77 ms
76,672 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[x][y] == 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[x][y] == -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