QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#569179#7875. Queue Sortingheige#WA 60ms4876kbC++141012b2024-09-16 21:09:182024-09-16 21:09:18

Judging History

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

  • [2024-09-16 21:09:18]
  • 评测
  • 测评结果:WA
  • 用时:60ms
  • 内存:4876kb
  • [2024-09-16 21:09:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn = 505, mod = 998244353;
int n;
int a[maxn], s[maxn];
int dp[2][maxn][maxn];
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], s[i] = s[i - 1] + a[i];
    for (int i = 1; i <= n; i++)
        if (a[i]) dp[1][i][1] = 1;
    for (int i = 1; i < s[n]; i++) {
        int p = (i & 1);
        for (int j = 0; j <= n; j++)
            for (int k = 0; k <= s[n]; k++)
                dp[p ^ 1][j][k] = 0;
        for (int j = 1; j <= n; j++)
            for (int k = 1; k <= a[j]; k++) {
                if (i != s[j]) dp[p ^ 1][j][k] = (dp[p ^ 1][j][k] + dp[p][j][k]) % mod;
                if (k != a[j]) dp[p ^ 1][j][k + 1] = (dp[p ^ 1][j][k + 1] + dp[p][j][k]) % mod;
                for (int x = j + 1; x <= n; x++) dp[p ^ 1][x][1] = (dp[p ^ 1][x][1] + dp[p][j][k]) % mod;
            }
    }
    cout << dp[s[n] & 1][n][a[n]] << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 60ms
memory: 4876kb

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:

411666975

result:

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