QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#569171#7875. Queue Sortingheige#WA 1ms3732kbC++14855b2024-09-16 21:06:542024-09-16 21:06:55

Judging History

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

  • [2024-09-16 21:06:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3732kb
  • [2024-09-16 21:06:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn = 105, mod = 998244353;
int n;
int a[maxn], s[maxn];
int dp[maxn][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++)
        for (int j = 1; j <= n; j++)
            for (int k = 1; k <= a[j]; k++) {
                if (i != s[j]) dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k]) % mod;
                if (k != a[j]) dp[i + 1][j][k + 1] = (dp[i + 1][j][k + 1] + dp[i][j][k]) % mod;
                for (int x = j + 1; x <= n; x++) dp[i + 1][x][1] = (dp[i + 1][x][1] + dp[i][j][k]) % mod;
            }
    cout << dp[s[n]][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: 3732kb

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3572kb

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:

0

result:

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