QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408062#5524. Help Me to Get This Publisheducup-team173WA 1ms3772kbC++201.8kb2024-05-09 17:16:462024-05-09 17:16:47

Judging History

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

  • [2024-05-09 17:16:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3772kb
  • [2024-05-09 17:16:46]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define db double

using namespace std;

const int Mod = 998244353;

int f[105][105][105];

void add(int&x, int y) {
    x += y; 
    x >= Mod ? x -= Mod : 0;
}

int Fpow(int x, int k) {
    int ans = 1; 
    for (; k; k >>= 1, x = 1ll * x * x % Mod) {
        if (k & 1) {
            ans = 1ll * ans * x % Mod;
        }
    }
    return ans;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n, 0);
    int m = 0;
    vector<int> Inv(n + 1, 0), Fac(n + 1, 0);
    Fac[0] = 1;
    for (int i = 1; i <= n; i++) {
        Fac[i] = 1ll * Fac[i - 1] * i % Mod;
    }
    Inv[n] = Fpow(Fac[n], Mod - 2);
    for (int i = n; i >= 1; i--) {
        Inv[i - 1] = 1ll * Inv[i] * i % Mod;
    }
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x == -1) m++;
        else a[x]++;
    }
    int flag = 0;
    for (int t = n - 1; t >= 1; t--) {
        for (int num = 1; num <= n; num++) {
            for (int p = 0; num + p + a[t] <= n; p++) {
                for (int l = 2; (l >> 1) + p + a[t] <= n; l++) {
                    add(f[t][(l >> 1) + p + a[t]][num + p + a[t]], 1ll * f[t + 1][l][num] * Inv[p] % Mod);
                }
            }
        }
        if (!flag) {
            for (int p = 0; p <= n; p++) {
                f[t][p + a[t]][p + a[t]] = Inv[p];
            }
        }
        if (a[t]) {
           flag = 1;
        }
    }
    int ans = 0;
    for(int t = 2; t <= n; t++) {
        add(ans, f[1][t][n]);
    }
}

int main() {
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3772kb

input:

2
1 -1

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements