QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86719 | #4807. Melborp Lacissalc | codicon | WA | 3ms | 5384kb | C++20 | 1.6kb | 2023-03-10 17:37:40 | 2023-03-10 17:37:43 |
Judging History
answer
//
// Created by codicon on 3/9/2023 at 6:56 PM.
//
// O(n^5/2^2) = 2.5e8 ==> Make sure you precompute n choose k to avoid 2 expensive mod operations per call
// The idea is that there is a bijection between the n + 1 prefix sums and the n values of the array
#include <bits/stdc++.h>
using namespace std;
# define add(a, b) a = ((a) + (b)) % MOD;
int n, k, t;
const int MAXN = 64, MOD = 998'244'353;
int dp[MAXN + 1][MAXN + 2][(MAXN)*(MAXN+1)/2 + 1];
long long ch[MAXN+2][MAXN+2];
void set_up() {
ch[0][0] = 1;
for (int n = 1; n <= MAXN+1; n++) {
for (int k = 0; k <= MAXN+1; k++) {
ch[n][k] = ch[n-1][k] + (k-1 ? ch[n-1][k-1] : 0);
}
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> k >> t;
set_up();
// Base case
for (int used = 1; used <= n+1; used++) {
dp[1][used][ch[used][2]] = 1;
}
// Do dp
for (int pused = 1; pused < k; pused++) {
for (int used = 1; used <= n+1; used++) {
for (int goodness = 0; goodness <= t; goodness++) {
// Use new_used of the new prefix value
for (int new_used = 0;
new_used + used <= n+1 and
goodness + ch[new_used][2] <= t;
new_used++) {
add(dp[pused + 1][used + new_used][goodness + ch[new_used][2]],
dp[pused][used][goodness] * ch[used-1 + new_used][new_used] % MOD)
}
}
}
}
cout << dp[k][n+1][t];
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 5384kb
input:
2 5 1
output:
0
result:
wrong answer 1st numbers differ - expected: '12', found: '0'