QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#86717#4807. Melborp LacissalccodiconRE 0ms0kbC++201.6kb2023-03-10 17:35:592023-03-10 17:36:01

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-10 17:36:01]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-03-10 17:35:59]
  • 提交

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+1][MAXN+1];

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];
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

2 5 1

output:


result: