/* -*- coding: utf-8 -*- * * 2708.cc: No.2708 Jewel holder - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_H = 10; const int MAX_W = 10; /* typedef */ typedef long long ll; typedef map mil; /* global variables */ char fs[MAX_H][MAX_W + 4]; mil ds[MAX_H][MAX_W]; /* subroutines */ /* main */ int main() { int h, w; scanf("%d%d", &h, &w); for (int y = 0; y < h; y++) scanf("%s", fs[y]); ds[0][0][1] = 1; for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) if (! ds[y][x].empty()) { if (y + 1 < h && fs[y + 1][x] != '#') { int dd = (fs[y + 1][x] == 'o') ? 1 : -1; for (auto [ud, uc]: ds[y][x]) { int vd = ud + dd; if (vd >= 0) ds[y + 1][x][vd] += uc; } } if (x + 1 < w && fs[y][x + 1] != '#') { int dd = (fs[y][x + 1] == 'o') ? 1 : -1; for (auto [ud, uc]: ds[y][x]) { int vd = ud + dd; if (vd >= 0) ds[y][x + 1][vd] += uc; } } } ll sum = 0; for (auto [d, c]: ds[h - 1][w - 1]) sum += c; printf("%lld\n", sum); return 0; }