結果
| 問題 |
No.2646 Cycle Maze
|
| ユーザー |
rlangevin
|
| 提出日時 | 2024-02-26 12:24:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,073 bytes |
| コンパイル時間 | 317 ms |
| コンパイル使用メモリ | 82,408 KB |
| 実行使用メモリ | 304,460 KB |
| 最終ジャッジ日時 | 2024-09-29 11:36:33 |
| 合計ジャッジ時間 | 15,867 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 47 WA * 4 |
ソースコード
import sys
input = sys.stdin.readline
from collections import *
M = 605
def f(h, w, t):
return h * W * M + w * M + t
def g(v):
t = v % M
v //= M
h, w = divmod(v, W)
return h, w, t
H, W, T = map(int, input().split())
sx, sy = map(int, input().split())
gx, gy = map(int, input().split())
sx, sy, gx, gy = sx - 1, sy - 1, gx - 1, gy - 1
A = []
for i in range(H):
L = list(input().rstrip())
L = list(map(int, L))
A.append(L)
seen = [0] * H * W * (M+1)
Q = deque()
Q.append(f(sx, sy, 0))
seen[f(sx, sy, 0)] = 1
dx = [1, 0, -1, 0, 0]
dy = [0, 1, 0, -1, 0]
while Q:
v = Q.popleft()
h, w, t = g(v)
if h == gx and w == gy:
print("Yes")
exit()
if t == T+1:
break
for k in range(5):
x = h + dx[k]
y = w + dy[k]
if x < 0 or x > H - 1 or y < 0 or y > W - 1:
continue
b = (A[x][y] - t - 1) % (A[x][y] + 1)
if b == 0 or seen[f(x, y, t+1)]:
continue
seen[f(x, y, t+1)] = 1
Q.append(f(x, y, t+1))
print("No")
rlangevin