結果
問題 | No.2646 Cycle Maze |
ユーザー |
|
提出日時 | 2024-02-25 20:43:53 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,206 bytes |
コンパイル時間 | 228 ms |
コンパイル使用メモリ | 82,400 KB |
実行使用メモリ | 247,352 KB |
最終ジャッジ日時 | 2024-09-29 11:15:44 |
合計ジャッジ時間 | 27,625 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 TLE * 1 -- * 7 |
ソースコード
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 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')