結果

問題 No.3071 Double Speedrun
ユーザー t98slider
提出日時 2025-03-21 23:16:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 320 ms / 6,000 ms
コード長 976 bytes
コンパイル時間 4,696 ms
コンパイル使用メモリ 257,184 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-21 23:16:29
合計ジャッジ時間 7,885 ms
ジャッジサーバーID
(参考情報)
judge6 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> A(h);
    cin >> A;
    vector dp(w, vector<mint>(w));
    dp[0][1] = 1;
    for(int y = 0; y < h; y++){
        for(int x2 = 0; x2 < w; x2++){
            for(int x1 = 0; x1 < x2; x1++){
                if(A[y][x1] == '#' || A[y][x2] == '#') dp[x1][x2] = 0;
                if(x1 + 1 < x2 && A[y][x1 + 1] == '.') dp[x1 + 1][x2] += dp[x1][x2];
            }
        }
        for(int x1 = 0; x1 < w; x1++){
            for(int x2 = x1 + 1; x2 < w; x2++){
                if(x2 + 1 < w && A[y][x2 + 1] == '.') dp[x1][x2 + 1] += dp[x1][x2];
            }
        }
    }
    cout << dp[w - 2][w - 1].val() << '\n';
}
0