結果
| 問題 |
No.2708 Jewel holder
|
| ユーザー |
|
| 提出日時 | 2024-11-01 21:34:41 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,151 bytes |
| コンパイル時間 | 1,007 ms |
| コンパイル使用メモリ | 75,916 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-01 21:34:43 |
| 合計ジャッジ時間 | 2,092 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 9 WA * 8 |
ソースコード
#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)
sum = 0;
// cout << i << ' ' << j << ' ' << sum << endl;
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();
// cout << cells[i][j] << ' ';
}
// cout << endl;
}
int cnt = walk(0, 0, 0);
// cout << H << W << endl;
cout << cnt << endl;
}