結果
| 問題 | No.2708 Jewel holder | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-03-31 17:07:26 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 29 ms / 2,000 ms | 
| コード長 | 509 bytes | 
| コンパイル時間 | 432 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 10,880 KB | 
| 最終ジャッジ日時 | 2024-09-30 21:08:40 | 
| 合計ジャッジ時間 | 1,377 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
from sys import setrecursionlimit
setrecursionlimit(10**8)
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
ans = 0
def dfs(i, j, jewel):
    global ans
    if A[i][j] == "o":
        jewel += 1
    elif A[i][j] == "x":
        jewel -= 1
    else:
        return
    if jewel < 0:
        return
    if i == H - 1 and j == W - 1:
        ans += 1
        return
    if i + 1 < H:
        dfs(i + 1, j, jewel)
    if j + 1 < W:
        dfs(i, j + 1, jewel)
dfs(0, 0, 0)
print(ans)
            
            
            
        