QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#569171 | #7875. Queue Sorting | heige# | WA | 1ms | 3732kb | C++14 | 855b | 2024-09-16 21:06:54 | 2024-09-16 21:06:55 |
Judging History
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;
}
详细
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'