結果
| 問題 |
No.2708 Jewel holder
|
| ユーザー |
|
| 提出日時 | 2024-11-01 20:42:45 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,265 bytes |
| コンパイル時間 | 3,725 ms |
| コンパイル使用メモリ | 278,492 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-01 20:43:17 |
| 合計ジャッジ時間 | 5,764 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 4 RE * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<P> VP;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define OUT(n) cout << n << "\n"
// constexpr ll MOD=998244353;
// constexpr ll MOD=1000000007;
// constexpr ll INF=2e18;
ll ans = 0;
void generatePaths(int right, int down, ll cnt, VVI &A, ll x, ll y) {
if (A[x][y] == 'o') {
cnt += 1;
} else if (A[x][y] == 'x') {
cnt -= 1;
} else {
return;
}
if (cnt < 0) {
return;
}
// 右に移動できるなら
if (right > 0 ) {
generatePaths(right - 1, down, cnt, A, x + 1, y);
}
// 下に移動できるなら
if (down > 0) {
generatePaths(right, down - 1, cnt, A, x, y + 1);
}
if (right == 0 && down == 0) {
ans += 1;
return;
}
return;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
ll H, W;
cin >> H >> W;
VVI A(H, VI(W));
REP(i, H)
{
REP(j, W)
{
char c;
cin >> c;
A[i][j] = c;
}
}
generatePaths(W - 1, H - 1, 0, A, 0, 0);
OUT(ans);
}