Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <assert.h>
- #include <bits/stdc++.h>
- using namespace std;
- #ifndef __DEBUG__
- #define dbg(...) 42
- #endif
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using ll = long long;
- using pii = pair<int, int>;
- using pll = pair<ll, ll>;
- using vl = vector<ll>;
- using vi = vector<int>;
- constexpr int mod = 998244353;
- int main(int argc, char **argv)
- {
- int n, m;
- cin >> n >> m;
- vector<string> vs(n);
- for (auto &s : vs)
- cin >> s;
- ll ans = 0;
- auto get_first_row = [&](int col) {
- for (int i = 0; i < n; ++i)
- if (vs[i][col] == '#')
- return i;
- return n;
- };
- vector<int> fbs(m, n);
- for (int i = 0; i < m; ++i)
- fbs[i] = get_first_row(i);
- vector<ll> dp(n + 2, 0);
- for (int i = fbs[0]; i >= 0; --i)
- dp[i] = dp[i + 1] + 1;
- for (int i = 1; i < m; ++i) {
- vector<ll> ndp(n + 2, 0);
- for (int j = fbs[i]; j >= 0; --j)
- ndp[j] = (ndp[j + 1] + (j >= 1 ? dp[j - 1] : dp[0])) % mod;
- dp.swap(ndp);
- }
- cout << dp[0] << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement