結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー umimelumimel
提出日時 2022-11-25 22:02:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,155 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 163,464 KB
実行使用メモリ 73,856 KB
最終ジャッジ日時 2024-04-10 03:12:27
合計ジャッジ時間 3,123 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 65 ms
51,072 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 95 ms
73,856 KB
testcase_08 AC 49 ms
38,784 KB
testcase_09 AC 96 ms
73,856 KB
testcase_10 AC 96 ms
73,728 KB
testcase_11 AC 79 ms
62,208 KB
testcase_12 AC 76 ms
60,544 KB
testcase_13 AC 4 ms
6,940 KB
testcase_14 AC 54 ms
41,600 KB
testcase_15 AC 49 ms
37,632 KB
testcase_16 AC 5 ms
6,940 KB
testcase_17 AC 46 ms
35,840 KB
testcase_18 AC 45 ms
36,096 KB
testcase_19 AC 33 ms
26,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 998244353;
const ll INF = 1LL << 60;
const ll MAX_N = 2e5;

ll dp[3001][1001][3];

int main(){
    ll n;
    cin >> n;

    dp[0][0][0] = 1;
    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=1000; j++){
            //cの場合
            dp[i][j][1] = (dp[i][j][1] + dp[i-1][j][0])%MOD;

            //oの場合
            dp[i][j][2] = (dp[i][j][2] + dp[i-1][j][1])%MOD;

            //nの場合
            if(j <= 999) dp[i][j+1][0] = (dp[i][j+1][0] + dp[i-1][j][2])%MOD;

            //その他
            dp[i][j][0] = (dp[i][j][0] + dp[i-1][j][0]*25)%MOD;
            dp[i][j][1] = (dp[i][j][1] + dp[i-1][j][1]*25)%MOD;
            dp[i][j][2] = (dp[i][j][2] + dp[i-1][j][2]*25)%MOD;
        }
    }

    ll ans = 0;
    for(ll j=0; j<=1000; j++) for(ll k=0; k<=2; k++){
        ans = (ans + dp[n][j][k]*j)%MOD;
    }

    cout << ans << endl;
}
0