#include using namespace std; #define rep(i,n) for(int i = 0;i < n;i++) template bool chmin(T &a,T b){ if(a>b){a = b;return true;} return false; } template bool chmax(T &a,T b){ if(a> H >> W; vectorA(H); rep(i,H)cin >> A[i]; //→H個↓W個の並び替え int res = 0; auto dfs = [&](auto &dfs,int i,int j,int now){ if(i==H-1&&j==W-1&&now>=0){res++;return;} rep(d,2){ int ni = i+dx[d],nj = j+dy[d]; if(ni>=H||nj>=W)continue; if(A[ni][nj]=='#')continue; if(now==0&&A[ni][nj]=='x')continue; dfs(dfs,ni,nj,(A[ni][nj]=='x'?now-1:now+1)); } }; dfs(dfs,0,0,1); cout << res << endl; }