結果
問題 | No.3071 Double Speedrun |
ユーザー |
|
提出日時 | 2025-03-21 22:15:24 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 565 ms / 6,000 ms |
コード長 | 1,945 bytes |
コンパイル時間 | 9,842 ms |
コンパイル使用メモリ | 493,300 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2025-03-21 22:15:39 |
合計ジャッジ時間 | 13,956 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> #include <unordered_map> #include <stdlib.h> #include <boost/multiprecision/cpp_int.hpp> #include <atcoder/all> using namespace atcoder; using namespace boost::multiprecision; using namespace std; #define rep(i, a, n) for(ll i = a; i < n; i++) #define rrep(i, a, n) for(ll i = a; i >= n; i--) #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define all(x) (x).begin(), (x).end() //constexpr ll MOD = 1000000007; constexpr ll MOD = 998244353; constexpr int IINF = 1001001001; constexpr ll INF = 1LL<<60; template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;} template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;} using mint = modint998244353; ll gcd(ll a, ll b){ if(a%b == 0){ return b; }else{ return gcd(b, a%b); } } ll lcm(ll a, ll b){ return a*b / gcd(a, b); } ll powMod(ll x, ll n) { if (n == 0) return 1 % MOD; ll val = powMod(x, n / 2); val *= val; val %= MOD; if (n % 2 == 1) val *= x; return val % MOD; } int main() { ll h, w; cin >> h >> w; vector<string> s(h); rep(i,0,h) cin >> s[i]; vector<vector<mint>> dp(h,vector<mint>(h,0)); dp[1][0] = 1; vector<ll> dj = {0,0,1,1}, dk = {0,1,0,1}; rep(i,2,h+w-2){ vector<vector<mint>> ndp(h,vector<mint>(h,0)); rep(j,0,h)rep(k,0,h){ if(dp[j][k] == 0) continue; rep(id,0,4){ ll nj = j+dj[id], nk = k + dk[id]; if(nj >= h || nj == nk) continue; if(i-nk >= w) continue; // cout << nj << " " << nk << " " << i << endl; if(s[nj][i-nj] == '#' || s[nk][i-nk] == '#') continue; ndp[nj][nk] += dp[j][k]; } } swap(dp, ndp); } cout << dp[h-1][h-2].val() << endl; // rep(i,0,h){ // rep(j,0,h)cout << dp[h+w-23][i][j].val() << " "; // cout << endl; // } return 0; }