結果
問題 |
No.2708 Jewel holder
|
ユーザー |
![]() |
提出日時 | 2024-03-31 13:46:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,154 bytes |
コンパイル時間 | 4,579 ms |
コンパイル使用メモリ | 256,608 KB |
最終ジャッジ日時 | 2025-02-20 16:33:18 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; int main() { ll H, W; cin >> H >> W; vector<string> A(H); for (ll i = 0; i < H; i++) { cin >> A[i]; } vector<vector<vector<ll>>> dp(H, vector<vector<ll>>(W, vector<ll>(30, 0))); dp[0][0][1] = 1; for (ll i = 0; i < H; i++) { for (ll j = 0; j < W; j++) { ll d; if (A[i][j] == '#') { continue; } else if (A[i][j] == 'x') { d = -1; } else { d = 1; } for (ll k = 0; k < 30; k++) { ll nk = k - d; if (nk < 0 || nk >= 30) { continue; } if (i > 0) { dp[i][j][k] += dp[i - 1][j][nk]; } if (j > 0) { dp[i][j][k] += dp[i][j - 1][nk]; } } } } ll ans = 0; for (ll k = 0; k < 30; k++) { ans += dp[H - 1][W - 1][k]; } cout << ans << endl; return 0; }