結果
| 問題 |
No.2646 Cycle Maze
|
| ユーザー |
|
| 提出日時 | 2024-02-25 20:47:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,261 bytes |
| コンパイル時間 | 353 ms |
| コンパイル使用メモリ | 81,780 KB |
| 実行使用メモリ | 309,436 KB |
| 最終ジャッジ日時 | 2024-09-29 11:16:05 |
| 合計ジャッジ時間 | 18,993 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 WA * 4 TLE * 1 -- * 3 |
ソースコード
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(T+1)] 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()
if x == gx and y == gy:
exit(print('Yes'))
if t == T:
continue
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))
ans = 10**18
for i in range(T+1):
ans = min(ans,dist[gx][gy][i])
print('Yes' if ans < T else 'No')