結果
| 問題 | No.2131 Concon Substrings (COuNt Version) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-25 21:40:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 2,000 ms |
| コード長 | 1,020 bytes |
| コンパイル時間 | 1,629 ms |
| コンパイル使用メモリ | 192,988 KB |
| 最終ジャッジ日時 | 2025-02-09 00:04:34 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
const ll MOD=998244353;
int n;
ll dp[3010][1010][3];
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n;
dp[0][0][0]=1;
rep(i,n){
rep(j,n/3+1){
dp[i+1][j+1][0]+=dp[i][j][2];
dp[i+1][j+1][0]%=MOD;
dp[i+1][j][1]+=dp[i][j][0];
dp[i+1][j][2]+=dp[i][j][1];
rep(k,3){
dp[i+1][j][k]+=25*dp[i][j][k];
dp[i+1][j][k]%=MOD;
}
}
}
ll ans=0;
rep(i,n/3+1){
rep(j,3){
ans+=i*dp[n][i][j];
ans%=MOD;
}
}
cout<<ans<<"\n";
}