結果

問題 No.2646 Cycle Maze
ユーザー hato336hato336
提出日時 2024-02-25 20:47:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,261 bytes
コンパイル時間 475 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 286,136 KB
最終ジャッジ日時 2024-02-25 20:47:40
合計ジャッジ時間 19,389 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
91,756 KB
testcase_01 AC 134 ms
84,952 KB
testcase_02 AC 128 ms
84,952 KB
testcase_03 AC 129 ms
85,080 KB
testcase_04 AC 128 ms
84,952 KB
testcase_05 AC 154 ms
84,952 KB
testcase_06 WA -
testcase_07 AC 128 ms
84,952 KB
testcase_08 AC 129 ms
84,952 KB
testcase_09 AC 130 ms
84,952 KB
testcase_10 AC 138 ms
88,280 KB
testcase_11 AC 139 ms
88,280 KB
testcase_12 WA -
testcase_13 AC 137 ms
84,952 KB
testcase_14 AC 129 ms
84,952 KB
testcase_15 AC 128 ms
84,952 KB
testcase_16 WA -
testcase_17 AC 128 ms
84,952 KB
testcase_18 WA -
testcase_19 AC 138 ms
88,280 KB
testcase_20 AC 130 ms
84,952 KB
testcase_21 AC 131 ms
84,952 KB
testcase_22 AC 139 ms
85,080 KB
testcase_23 AC 128 ms
84,952 KB
testcase_24 AC 128 ms
84,952 KB
testcase_25 AC 255 ms
138,328 KB
testcase_26 AC 287 ms
124,632 KB
testcase_27 AC 511 ms
140,632 KB
testcase_28 AC 210 ms
97,112 KB
testcase_29 AC 261 ms
140,376 KB
testcase_30 AC 253 ms
123,224 KB
testcase_31 AC 189 ms
104,024 KB
testcase_32 AC 171 ms
89,048 KB
testcase_33 AC 221 ms
99,288 KB
testcase_34 AC 334 ms
113,368 KB
testcase_35 AC 326 ms
121,560 KB
testcase_36 AC 266 ms
99,672 KB
testcase_37 AC 226 ms
114,904 KB
testcase_38 AC 163 ms
89,432 KB
testcase_39 AC 253 ms
122,456 KB
testcase_40 AC 152 ms
89,176 KB
testcase_41 AC 275 ms
120,280 KB
testcase_42 AC 206 ms
92,760 KB
testcase_43 AC 169 ms
89,560 KB
testcase_44 AC 211 ms
100,184 KB
testcase_45 AC 931 ms
174,444 KB
testcase_46 AC 845 ms
192,088 KB
testcase_47 AC 428 ms
264,920 KB
testcase_48 AC 604 ms
169,048 KB
testcase_49 AC 921 ms
276,696 KB
testcase_50 AC 1,681 ms
237,400 KB
testcase_51 TLE -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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')
0