結果
| 問題 |
No.2708 Jewel holder
|
| コンテスト | |
| ユーザー |
ななな
|
| 提出日時 | 2024-03-31 14:45:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 939 bytes |
| コンパイル時間 | 1,666 ms |
| コンパイル使用メモリ | 172,096 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-30 19:54:48 |
| 合計ジャッジ時間 | 2,269 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 5 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
vector<vector<char>> c(10, vector<char>(10));
vector<int> x = {0, 1};
vector<int> y = {1, 0};
int h, w;
int ans = 0;
void dfs(int i, int j, int cost) {
if (i == h - 1 && j == w - 1) {
int i1 = i;
int j1 = j;
if (c[i1][j1] == 'o') {
ans++;
} else {
if (cost != 0)
ans++;
}
} else {
for (int t = 0; t < 2; t++) {
int i1 = i + x[t];
int j1 = j + y[t];
if (i1 < 0 || i1 >= h)
continue;
if (j1 < 0 || j1 >= w)
continue;
if (c[i1][j1] == '#')
continue;
else if (c[i1][j1] == 'o') {
dfs(i1, j1, cost + 1);
} else {
if (cost != 0)
dfs(i1, j1, cost - 1);
}
}
}
}
signed main() {
cin >> h >> w;
rep(i, h) { rep(j, w) cin >> c[i][j]; }
dfs(0, 0, 1);
cout << ans << endl;
}
ななな