結果

問題 No.2708 Jewel holder
ユーザー harurunharurun
提出日時 2024-03-31 15:12:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,646 bytes
コンパイル時間 5,984 ms
コンパイル使用メモリ 428,440 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-31 15:12:42
合計ジャッジ時間 6,729 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 1 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 1 ms
6,548 KB
testcase_15 AC 1 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 1 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <stack>
#include <random>
#include <complex>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <assert.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#if __has_include(<boost/multiprecision/cpp_int.hpp>)
#include <boost/multiprecision/cpp_int.hpp>
using cpp_int=boost::multiprecision::cpp_int;
#endif
#if __has_include(<boost/multiprecision/cpp_dec_float.hpp>)
#include <boost/multiprecision/cpp_dec_float.hpp>
template<unsigned size>using cpp_float=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<size>>;
template<unsigned size>using cpp_double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<size,long long>>;
#endif
using namespace std;
using ll=long long;
#define read(x) cin>>(x);
#define readll(x) ll (x);cin>>(x);
#define readS(x) string (x);cin>>(x);
#define readvll(x,N) vector<ll> (x)((N));for(int i=0;i<(N);i++){cin>>(x)[i];}
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define rep2d(i,j,H,W) for(ll (i)=0;(i)<(H);(i)++)for(ll (j)=0;(j)<(W);j++)
#define is_in(x,y) (0<=(x) && (x)<H && 0<=(y) && (y)<W)
#define yn {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define double_out(x) fixed << setprecision(x)
template<class T> inline void erase_duplicate(vector<T>& A){sort(A.begin(),A.end());A.erase(unique(A.begin(),A.end()),A.end());}
inline ll powll(ll x,ll n){ll r=1;while(n>0){if(n&1){r*=x;};x*=x;n>>=1;};return r;}


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>(H*W+1)));
  dp[0][0][1]=1;
  for(ll i=0;i<H;i++){
    for(ll j=0;j<W;j++){
      for(ll k=0;k<H*W+1;k++){
        if(i+1<H){
          if(A[i+1][j]=='o'){
            if(k+1<H*W+1){
              dp[i+1][j][k+1]+=dp[i][j][k];
            }
          }
          if(A[i+1][j]=='x'){
            if(k-1>=0){
              dp[i+1][j][k-1]+=dp[i][j][k];
            }
          }
        }
        if(j+1<W){
          if(A[i][j+1]=='o'){
            if(k+1<H*W+1){
              dp[i][j+1][k+1]+=dp[i][j][k];
            }
          }
          if(A[i][j+1]=='x'){
            if(k-1>=0){
              dp[i][j+1][k-1]+=dp[i][j][k];
            }
          }
        }
      }
    }
  }
  ll ans=0;
  for(ll i=0;i<H*W+1;i++){
    ans+=dp[H-1][W-1][i];
  }
  cout<<ans<<endl;
}
0