QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#760236 | #9740. Aho-Corasick 自动机 | Symmetree | WA | 0ms | 3932kb | C++17 | 1.1kb | 2024-11-18 15:47:27 | 2024-11-18 15:47:34 |
Judging History
answer
#include<bits/stdc++.h>
using i64 = long long;
using pii = std::pair<int,int>;
const int N = 105, mod = 998244353;
int n, m, d, f[N][N][N], g[N][N], c[N][N];
signed main() {
scanf("%d%d%d", &n, &m, &d);
for(int i = 0; i <= m; ++i) c[i][0] = c[i][i] = 1;
for(int i = 1; i <= m; ++i)
for(int j = 1; j <= m; ++j)
c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
g[0][0] = 1;
for(int i = 1; i <= n; ++i)
for(int j = 0; j <= n; ++j)
for(int k = 0; k <= std::min(m, j); ++k)
g[i][j] = (g[i][j] + 1ll * g[i - 1][j - k] * c[m][k] % mod) % mod;
f[0][1][1] = 1;
for(int i = 1; i <= d; ++i)
for(int j = 1; j <= n; ++j)
for(int k = 1; k <= j; ++k)
for(int t = 1; t <= j - k; ++t)
f[i][j][k] = (f[i][j][k] + 1ll * f[i - 1][j - k][t] * g[t][k] % mod) % mod;
int ans = 0;
for(int i = 1; i <= d; ++i)
for(int j = 1; j <= n; ++j)
ans += f[i][n][j], ans %= mod;
printf("%d\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3932kb
input:
3 2 2
output:
5
result:
ok answer is '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
4 2 2
output:
6
result:
ok answer is '6'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3828kb
input:
1 1 1
output:
0
result:
wrong answer expected '1', found '0'