結果
| 問題 | No.2708 Jewel holder |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-31 13:47:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,257 bytes |
| 記録 | |
| コンパイル時間 | 3,658 ms |
| コンパイル使用メモリ | 242,292 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-09-30 18:23:47 |
| 合計ジャッジ時間 | 4,322 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 5 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using mint = atcoder::modint998244353;
#define int long long
signed main() {
int h,w;
cin >> h >> w;
vector<string> s(h);
for(int i = 0; i < h; i++) cin >> s[i];
vector<vector<vector<int>>> dp(h,vector<vector<int>>(w,vector<int>(h*w+1,0)));
dp[0][0][1]++;
deque<pair<int,int>> q;
q.push_back({0,0});
vector<vector<bool>> v(h,vector<bool>(w,false));
vector<vector<bool>> z = v;
z[0][0] = true;
while(q.size() > 0) {
int x,y;
tie(x,y) = q.front();
v[x][y] = true;
q.pop_front();
if(x != h-1 && !v[x+1][y] && s[x+1][y] != '#') {
int t = 1;
if(s[x+1][y] == 'x') t-=2;
for(int i = 0; i <= h*w; i++) {
if(i+t >= 0 && i+t <= h*w) dp[x+1][y][i+t]+=dp[x][y][i];
}
if(!z[x+1][y]) q.push_back({x+1,y});
z[x+1][y] = true;
}
if(y != w-1 && !v[x][y+1] && s[x][y+1] != '#') {
int t = 1;
if(s[x][y+1] == 'x') t-=2;
for(int i = 0; i <= h*w; i++) {
if(i+t >= 0 && i+t <= h*w) dp[x][y+1][i+t]+=dp[x][y][i];
}
if(!z[x][y+1]) q.push_back({x,y+1});
z[x][y+1] = true;
}
}
int ans = 0;
for(int i = 1; i <= h*w; i++) ans+=dp[h-1][w-1][i];
cout << ans << endl;
}