QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#269201#7875. Queue Sortingucup-team1447#WA 61ms4676kbC++142.3kb2023-11-29 13:51:202023-11-29 13:51:21

Judging History

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

  • [2023-11-29 13:51:21]
  • 评测
  • 测评结果:WA
  • 用时:61ms
  • 内存:4676kb
  • [2023-11-29 13:51:20]
  • 提交

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 = pre[n]; 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: 1ms
memory: 4676kb

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 61ms
memory: 4620kb

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'