結果
問題 | No.3071 Double Speedrun |
ユーザー |
![]() |
提出日時 | 2025-03-21 22:29:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 678 ms / 6,000 ms |
コード長 | 2,227 bytes |
コンパイル時間 | 5,828 ms |
コンパイル使用メモリ | 271,060 KB |
実行使用メモリ | 16,768 KB |
最終ジャッジ日時 | 2025-03-21 22:30:11 |
合計ジャッジ時間 | 10,395 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge7 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
/** author: shobonvip created: 2025.03.21 22:22:16 **/ #include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) #define all(v) v.begin(), v.end() template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int h, w;cin >> h >> w; vector s(h,vector<char>(w)); rep(i,0,h)rep(j,0,w)cin>>s[i][j]; map<pair<int,int>,int>mp; vector pr(h+w-1,vector<pair<int,int>>(0)); rep(i,0,h){ rep(j,0,w){ if(s[i][j]!='#'){ mp[pair(i,j)]=(int)pr[i+j].size(); pr[i+j].push_back(pair(i,j)); } } } vector<vector<mint>> dp(1, vector<mint>(1)); dp[0][0] = 1; for (int i=0;i<h+w-2;i++) { vector seni((int)pr[i].size(),vector<int>(0)); rep(x,0,(int)pr[i].size()){ int p=pr[i][x].first; int q=pr[i][x].second; if(mp.find(pair(p+1,q))!=mp.end()){ seni[x].push_back(mp[pair(p+1,q)]); } if(mp.find(pair(p,q+1))!=mp.end()){ seni[x].push_back(mp[pair(p,q+1)]); } } vector<vector<mint>> ndp((int)pr[i+1].size(), vector<mint>((int)pr[i+1].size())); rep(x,0,(int)pr[i].size()){ rep(y,0,(int)pr[i].size()){ for(int dx:seni[x]){ for(int dy:seni[y]){ if(i!=h+w-3&&dx==dy)continue; ndp[dx][dy]+=dp[x][y]; } } } } swap(dp,ndp); } cout<<(dp[0][0]/2).val()<<endl; }