問題一覧 > 通常問題

No.2708 Jewel holder

レベル : / AI推定難易度 : 700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 204
作問者 : Nafmo2 / テスター : dyktr_06 sepa38 ryota2357
お気に入りにしたユーザー ProblemId : 9985 / 自分の提出
問題文最終更新日: 2024-03-31 13:39:57
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 425 (MMA Contest 018) (順位表) の他の問題:

Problem Statement

There is a grid with $H$ rows and $W$ columns. The cell in the $i$-th row from the top and the $j$-th column from the left is denoted by $(i,j)$.
When you reach a cell with o written on it, you receive 1 jewel, and when you reach a cell with x written on it, 1 jewel is confiscated.

For each $i,j (1 \leq i \leq H, 1\leq j \leq W)$, the information of cell $(i,j)$ is given by a character $A_{i,j}$.

If $A_{i,j}$ is o, you always receive 1 jewel when you reach cell $(i,j)$, and if $A_{i,j}$ is x, 1 jewel is always confiscated when you reach cell $(i,j)$.

It is guaranteed that cell $(1,1)$ is an o cell, where a jewel is always received.
It is also guaranteed that neither cell $(1,1)$ nor cell $(H,W)$ is a # cell.

Nafmo, holding $0$ jewels, reached cell $(1,1)$ and received $1$ jewel.
Nafmo wants to travel from cell $(1,1)$ to cell $(H,W)$ along a shortest route by repeatedly moving right and down. However, a route is invalid if a situation arises where Nafmo does not have even $1$ jewel when a jewel is to be confiscated.
Find the number of ways to choose a route satisfying the above conditions.

Added at 13:39: # cells cannot be passed through.

Input

$H \ W$
$A_{1,1}A_{1,2}\dots A_{1,W}$
$\ \vdots$
$A_{H,1}A_{H,2}\dots A_{H,W}$

  • $2 \leq H,W \leq 10$
  • $H,W$ are integers
  • $A_{i,j}$ is one of o, x, #
  • $A_{1,1} = $ o
  • $A_{H,W} \neq $ #

Output

Output the number of ways to choose a route satisfying the conditions.

Sample

Sample 1
Input
3 3
ooo
o#o
ooo
Output
2

The following are the 2 ways.

Sample 2
Input
3 3
oox
xxx
xoo
Output
3

The following $3$ ways are all of them.

Sample 3
Input
3 3
oxx
xxx
xxx
Output
0

Whichever route is chosen, it becomes impossible to pay a jewel before reaching the goal, so no route satisfies the conditions.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。