結果

問題 No.2708 Jewel holder
ユーザー 若杉勇弥
提出日時 2024-11-01 21:13:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 796 ms
コンパイル使用メモリ 76,120 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-01 21:13:30
合計ジャッジ時間 1,914 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 3 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXMONEY 300

int H, W;
vector<vector<int>> cells;

int check()
{
    string cell;
    cin >> cell;
    if (cell == "o")
        return 1;
    else if (cell == "x")
        return -1;
    else
        return 0;
}

int walk(int i, int j, uint sum)
{
    int cnt = 0;
    if (cells[i][j] == 0) // 通行止め
        return cnt;
    else // 通行可能
        sum += cells[i][j];

    if (i == H - 1 && j == W - 1) // goal
        return 1 ? sum == 0 : 0;

    if (i < H - 1)
        cnt += walk(i + 1, j, sum); // down
    if (j < W - 1)
        cnt += walk(i, j + 1, sum); // right

    return cnt;
}

int main()
{
    cin >> H >> W;
    cells = vector<vector<int>>(H, vector<int>(W));
    for (int i = 0; i < H; ++i)
        for (int j = 0; j < W; ++j)
            cells[i][j] = check();

    int cnt = 0;
    cnt += walk(0, 0, 0);
    cout << cnt << endl;
}
0