QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#269207 | #7875. Queue Sorting | ucup-team1447# | WA | 22ms | 4696kb | C++14 | 2.3kb | 2023-11-29 13:55:01 | 2023-11-29 13:55:02 |
Judging History
answer
// This Code was made by Chinese_zjc_.
#include <bits/stdc++.h>
// #define debug
const int MOD = 998244353;
struct mint
{
unsigned v;
mint(unsigned v_ = 0) : v(v_) {}
mint operator-() const { return v ? MOD - v : *this; }
mint &operator+=(const mint &X) { return (v += X.v) >= MOD ? v -= MOD : v, *this; }
mint &operator-=(const mint &X) { return (v += MOD - X.v) >= MOD ? v -= MOD : v, *this; }
mint &operator*=(const mint &X) { return v = 1llu * v * X.v % MOD, *this; }
mint &operator/=(const mint &X) { return *this *= X.inv(); }
mint pow(long long B) const
{
B %= MOD - 1;
if (B < 0)
B += MOD - 1;
mint res = 1, A = *this;
while (B)
{
if (B & 1)
res *= A;
B >>= 1;
A *= A;
}
return res;
}
mint inv() const { return pow(MOD - 2); }
friend mint operator+(const mint &A, const mint &B) { return mint(A) += B; }
friend mint operator-(const mint &A, const mint &B) { return mint(A) -= B; }
friend mint operator*(const mint &A, const mint &B) { return mint(A) *= B; }
friend mint operator/(const mint &A, const mint &B) { return mint(A) /= B; }
friend std::istream &operator>>(std::istream &A, mint &B) { return A >> B.v; }
friend std::ostream &operator<<(std::ostream &A, const mint &B) { return A << B.v; }
friend bool operator==(const mint &A, const mint &B) { return A.v == B.v; }
explicit operator bool() const { return v; }
} dp[505][505];
int n, a[505], b[505], pre[505];
signed main()
{
std::ios::sync_with_stdio(false);
std::cin >> n;
for (int i = 1; i <= n; ++i)
std::cin >> a[i], pre[i] = pre[i - 1] + a[i];
for (int i = 1; i <= n; ++i)
for (int j = pre[i - 1] + 1; j <= pre[i]; ++j)
b[j] = i;
dp[0][0] = 1;
for (int i = 0; i <= pre[n]; ++i)
{
for (int j = i; j >= 0; --j)
{
if (pre[b[i]] != i)
dp[i + 1][j] += dp[i][j];
for (int k = b[i] + 1; k <= n; ++k)
dp[pre[k - 1] + 1][j + pre[k - 1] - i] += dp[i][j];
if (j)
dp[i][j - 1] += dp[i][j];
}
}
std::cout << dp[pre[n]][0] << std::endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 4620kb
input:
4 1 1 1 1
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: -100
Wrong Answer
time: 22ms
memory: 4696kb
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:
687513720
result:
wrong answer 1st numbers differ - expected: '507010274', found: '687513720'