結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー FplusFplusFFplusFplusF
提出日時 2022-11-25 22:11:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,551 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 202,584 KB
実行使用メモリ 814,080 KB
最終ジャッジ日時 2024-04-10 03:20:10
合計ジャッジ時間 3,990 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i=0;i<(long long)(n);i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
const ll INF=(1ll<<60);
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int main(){
    const ll mod=998244353;
    ll n;
    cin >> n;
    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(26,vector<ll>(n+1,0)));
    dp[0][0][0]=1;
    rep(i,n){
        rep(j,26){
            rep(k,i+1){
                if(dp[i][j][k]==0) continue;
                //cout << ('o'-'a') << " " << ('n'-'a') << endl;
                
                rep(l,26){
                    if(k%3==0&&l==('c'-'a')){
                        dp[i+1][l][k+1]+=dp[i][j][k];
                        dp[i+1][l][k+1]%=mod;
                    }else if(k%3==1&&l==('o'-'a')){
                        dp[i+1][l][k+1]+=dp[i][j][k];
                        dp[i+1][l][k+1]%=mod;
                    }else if(k%3==2&&l==('n'-'a')){
                        dp[i+1][l][k+1]+=dp[i][j][k];
                        dp[i+1][l][k+1]%=mod;
                    }else{
                        dp[i+1][l][k]+=dp[i][j][k];
                        dp[i+1][l][k]%=mod;
                    }
                }
            }
        }
    }
    ll ans=0;
    rep(j,26){
        rep(k,n+1){
            ans+=k/3%mod*dp[n][j][k]%mod;
            ans%=mod;
        }
    }
    cout << ans << endl;
}
0