結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー umezoumezo
提出日時 2022-11-25 22:20:06
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 2,414 ms
コンパイル使用メモリ 202,868 KB
実行使用メモリ 49,920 KB
最終ジャッジ日時 2024-10-02 04:55:22
合計ジャッジ時間 3,351 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

const int MOD=998244353;
ll dp[3030][1010][3];
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  dp[0][0][0]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j*3<=i;j++){
      dp[i+1][j][0]=(dp[i+1][j][0]+dp[i][j][0]*25%MOD)%MOD;
      dp[i+1][j][1]=(dp[i+1][j][1]+dp[i][j][0]+dp[i][j][1]*25%MOD)%MOD;
      dp[i+1][j][2]=(dp[i+1][j][2]+dp[i][j][1]+dp[i][j][2]*25%MOD)%MOD;
      dp[i+1][j+1][0]=(dp[i+1][j+1][0]+dp[i][j][2])%MOD;
    }
  }
  ll ans=0;
  for(int j=1;j<=1000;j++){
    for(int k=0;k<3;k++){
      ans=(ans+dp[n][j][k]*j%MOD)%MOD;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}
0