Problem Statement
Grid Paths
Implementation
void solve()
{
ll n;
cin >> n;
vector<string> s(n);
rep(i, n) cin >> s[i];
if (s[0][0] == '*')
{
cout << 0 << "\n";
return;
}
vvll dp(n, vll(n, 0));
dp[0][0] = 1;
FOR(i, 1, n - 1)
if (s[0][i] != '*')
dp[0][i] = dp[0][i - 1];
FOR(i, 1, n - 1)
if (s[i][0] != '*')
dp[i][0] = dp[i - 1][0];
FOR(i, 1, n - 1)
{
FOR(j, 1, n - 1)
{
if (s[i][j] != '*')
{
if (i - 1 >= 0)
dp[i][j] += dp[i - 1][j];
dp[i][j] %= mod;
if (j - 1 >= 0)
dp[i][j] += dp[i][j - 1];
dp[i][j] %= mod;
}
}
}
cout << dp[n - 1][n - 1] << "\n";
}