結果
| 問題 |
No.2708 Jewel holder
|
| コンテスト | |
| ユーザー |
かもめのうで
|
| 提出日時 | 2024-03-31 14:11:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 873 bytes |
| コンパイル時間 | 272 ms |
| コンパイル使用メモリ | 82,040 KB |
| 実行使用メモリ | 55,616 KB |
| 最終ジャッジ日時 | 2024-09-30 19:07:24 |
| 合計ジャッジ時間 | 1,749 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 4 |
ソースコード
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
from collections import deque
dij = [(1, 0), (0, 1)]
q = deque()
visited = [[0]*w for _ in range(h)]
dist = [[1<<60]*w for _ in range(h)]
q.append((1, 0, 0))
visited[0][0] = 1
dist[0][0] = 0
used = set()
while q:
t, i, j = q.popleft()
for di, dj in dij:
ni = di+i
nj = dj+j
nt = t
if not (0<=ni<h and 0<=nj<w and a[ni][nj] != "#"):
continue
if dist[ni][nj] < dist[i][j] + 1:
continue
if a[ni][nj] == "x":
nt -= 1
else:
nt += 1
if nt < 0:
continue
if (i, j) in used:
continue
visited[ni][nj] += visited[i][j]
dist[ni][nj] = min(dist[ni][nj], dist[i][j]+1)
q.append((nt, ni, nj))
used.add((i, j))
print(visited[h-1][w-1])
かもめのうで