QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#278827#7875. Queue Sortingucup-team173#WA 26ms5204kbC++171.3kb2023-12-07 21:06:572023-12-07 21:06:58

Judging History

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

  • [2023-12-07 21:06:58]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:5204kb
  • [2023-12-07 21:06:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define Mp make_pair
#define SZ(x) (int((x).size()))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAXN = 505, Mod = 998244353;

int n;
int a[MAXN];
int f[MAXN][MAXN];
int C[MAXN][MAXN];
inline int Binom(int n, int m) {
    if(n < 0 || m < 0 || n < m) return 0;
    return C[n][m];    
}

void solve() {
    for(int i = 0; i <= 500; i++) {
        C[i][0] = 1;
        for(int j = 1; j <= i; j++) {
            C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
        }
    }
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    f[n + 1][0] = 1;
    for(int i = n; i >= 1; i--) {
        for(int j = 0; j <= n; j++) if(f[i + 1][j]) {
            for(int t = 0; t < a[i]; t++) {
                for(int k = 1; k <= j; k++) {
                    f[i][k + t] = (f[i][k + t] + 1ll * f[i + 1][j] * Binom(a[i] - t - 1 + (j - k), j - k)) % Mod;
                }
            } 
            f[i][j + a[i]] = (f[i][j + a[i]] + f[i + 1][j]) % Mod;
        }
    }
    int ans = 0;
    for(int i = 0; i <= n; i++) ans = (ans + f[1][i]) % Mod;
    cout << ans << '\n';
}
signed main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t = 1;
    while(t--) solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4672kb

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 26ms
memory: 5204kb

input:

300
0 5 2 2 1 0 3 2 2 5 2 1 1 2 1 3 2 3 2 0 0 0 0 1 2 2 3 0 2 2 3 2 0 2 3 0 6 0 0 2 0 1 3 2 1 1 1 3 4 0 1 0 4 1 1 1 1 1 1 2 3 2 1 2 3 2 3 0 5 3 3 2 0 1 1 0 2 1 1 2 0 0 2 1 1 3 2 2 1 2 1 3 0 3 0 1 2 2 0 5 0 2 2 0 0 0 1 2 1 4 2 1 1 0 3 0 2 0 3 1 1 2 0 2 1 1 0 2 0 1 2 2 3 3 1 1 1 1 0 1 3 3 1 0 2 2 4 2 ...

output:

593343539

result:

wrong answer 1st numbers differ - expected: '507010274', found: '593343539'