結果
| 問題 |
No.2646 Cycle Maze
|
| ユーザー |
|
| 提出日時 | 2024-02-25 20:36:10 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,181 bytes |
| コンパイル時間 | 420 ms |
| コンパイル使用メモリ | 82,260 KB |
| 実行使用メモリ | 235,480 KB |
| 最終ジャッジ日時 | 2024-09-29 11:13:43 |
| 合計ジャッジ時間 | 26,578 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 WA * 2 RE * 39 |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
input = sys.stdin.readline
#n = int(input())
#alist = list(map(int,input().split()))
#alist = []
#s = input()
h,w,T = map(int,input().split())
#for i in range(n):
# alist.append(list(map(int,input().split())))
sx,sy = map(lambda x:int(x)-1,input().split())
gx,gy = map(lambda x:int(x)-1,input().split())
grid = [list(map(int,list(input().rstrip()))) for i in range(h)]
start = (sx,sy,0)
d = collections.deque()
dist = [[[10**18 for i in range(210)] for j in range(w)] for feufr in range(h)]
d.append(start)
dist[sx][sy][0] = 0
dxy = [[-1,0],[1,0],[0,-1],[0,1],[0,0]]
while d:
x,y,t = d.popleft()
for dx,dy in dxy:
if 0 <= x+dx < h and 0 <= y+dy < w:
z = grid[x+dx][y+dy]
zz = (z - (t + 1)) % (z + 1)
if zz >= 1 and dist[x+dx][y+dy][t+1] > dist[x][y][t] + 1:
dist[x+dx][y+dy][t+1] = dist[x][y][t] + 1
d.append((x+dx,y+dy,(t+1)%210))
ans = 10**18
for i in range(210):
ans = min(ans,dist[gx][gy][i])
print('Yes' if ans <= T else 'No')