結果
問題 | No.2131 Concon Substrings (COuNt Version) |
ユーザー | ぷら |
提出日時 | 2022-11-25 21:29:20 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 1,604 bytes |
コンパイル時間 | 2,198 ms |
コンパイル使用メモリ | 196,256 KB |
実行使用メモリ | 67,712 KB |
最終ジャッジ日時 | 2024-04-10 02:40:04 |
合計ジャッジ時間 | 3,766 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 3 ms
6,944 KB |
testcase_03 | AC | 54 ms
35,584 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 | 111 ms
67,712 KB |
testcase_08 | AC | 33 ms
22,784 KB |
testcase_09 | AC | 110 ms
67,584 KB |
testcase_10 | AC | 109 ms
67,584 KB |
testcase_11 | AC | 79 ms
50,176 KB |
testcase_12 | AC | 75 ms
48,000 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 37 ms
25,472 KB |
testcase_15 | AC | 31 ms
21,760 KB |
testcase_16 | AC | 3 ms
6,940 KB |
testcase_17 | AC | 28 ms
20,224 KB |
testcase_18 | AC | 28 ms
20,352 KB |
testcase_19 | AC | 16 ms
13,184 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; constexpr int mod = 998244353; long long fac[200005], finv[200005], inv[200005]; void COMinit() { fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1; for (int i = 2; i < 200005; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } long long choose(int n,int k) { if(n < 0 || k < 0) return 0; if(n == 0) return 1; return COM(n+k-1,k-1); } long long modpow(long long a,long long b) { long long ans = 1; while(b) { if(b & 1) { (ans *= a) %= mod; } (a *= a) %= mod; b /= 2; } return ans; } void mpl(int &x,int y) { x += y; if(x >= mod) x -= mod; } int dp[3030][3030][3]; int main() { int N; cin >> N; dp[0][0][0] = 1; for(int i = 0; i < N; i++) { for(int j = 0; j <= i; j++) { for(int k = 0; k < 3; k++) { mpl(dp[i+1][j][k],dp[i][j][k]*25ll%mod); if(k == 2) { mpl(dp[i+1][j+1][0],dp[i][j][k]); } else { mpl(dp[i+1][j][k+1],dp[i][j][k]); } } } } int ans = 0; for(int i = 0; i <= N; i++) { int sum = 0; for(int j = 0; j < 3; j++) mpl(sum,dp[N][i][j]); mpl(ans,1ll*i*sum%mod); } cout << ans << endl; }