結果

問題 No.2708 Jewel holder
ユーザー くけ
提出日時 2024-03-31 13:42:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 968 bytes
コンパイル時間 4,216 ms
コンパイル使用メモリ 251,052 KB
最終ジャッジ日時 2025-02-20 16:28:17
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

ll DP[15][15][25] ;
char A[15][15] ;

int main(){
   ll h, w ;
   cin >> h >> w ;
   rep(i,h) rep(j,w) cin >> A[i][j] ;
   DP[0][0][1] = 1 ;
   rep(i,h){
      rep(j,w){
         rep(k,21){
            if( A[i][j] == '#' ) continue;
            if( i - 1 >= 0 ){
               if( A[i][j] == 'o' ) DP[i][j][k+1] += DP[i-1][j][k] ;
               if( A[i][j] == 'x' && k-1 >= 0 ) DP[i][j][k-1] += DP[i-1][j][k] ;
            }
            if( j - 1 >= 0 ){
               if( A[i][j] == 'o' ) DP[i][j][k+1] += DP[i][j-1][k] ;
               if( A[i][j] == 'x' && k-1 >= 0 ) DP[i][j][k-1] += DP[i][j-1][k] ;
            }
         }
      }
   }
   ll ans = 0 ;
   rep(k,25){
      ans += DP[h-1][w-1][k] ;
   }
   cout << ans << endl ;
}
0