結果
問題 |
No.2131 Concon Substrings (COuNt Version)
|
ユーザー |
![]() |
提出日時 | 2022-11-25 22:20:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,468 bytes |
コンパイル時間 | 1,827 ms |
コンパイル使用メモリ | 193,740 KB |
最終ジャッジ日時 | 2025-02-09 00:24:29 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 TLE * 1 |
other | AC * 8 TLE * 8 |
ソースコード
#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=int; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; 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; } } ll dp[3010][26][3010]; int main(){ const ll mod=998244353; ll n; cin >> n; 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; }