結果
問題 |
No.2708 Jewel holder
|
ユーザー |
|
提出日時 | 2024-11-01 21:43:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,140 bytes |
コンパイル時間 | 842 ms |
コンパイル使用メモリ | 75,292 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-01 21:43:09 |
合計ジャッジ時間 | 1,440 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define MAXMONEY 300 int H, W; vector<vector<int>> cells; int check() { char cell; cin >> cell; if (cell == 'o') return 1; else if (cell == 'x') return -1; else return 0; } int walk(int i, int j, int sum) { int cnt = 0; if (cells[i][j] == 0) // 通行止め return cnt; else // 通行可能 sum += cells[i][j]; if (sum < 0) return cnt; // cout << i << ' ' << j << ' ' << sum << endl; if (i == H - 1 && j == W - 1) // goal return 1; 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(); // cout << cells[i][j] << ' '; } // cout << endl; } int cnt = walk(0, 0, 0); // cout << H << W << endl; cout << cnt << endl; }