QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#336456#8278. Secret Poemsucup-team1191#WA 0ms5072kbC++203.4kb2024-02-24 16:35:392024-02-24 16:35:39

Judging History

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

  • [2024-02-24 16:35:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5072kb
  • [2024-02-24 16:35:39]
  • 提交

answer

#include <bits/stdc++.h>
#define fr first
#define sc second
#define all(a) (a).begin(), (a).end()
#define unique(a) a.resize(unique(a.begin(), a.end()) - a.begin())

using namespace std;

#ifdef ONPC
mt19937 rnd(223);
#else
mt19937 rnd(chrono::high_resolution_clock::now()
			.time_since_epoch().count());
#endif

#define TIME (clock() * 1.0 / CLOCKS_PER_SEC)

using ll = long long;
using ld = double;

const int maxn = 3e5 + 100, inf = 1e9 + 100;

// если модуль подается на вход, убрать все <> и раскомментировать нужные строки
using uint = unsigned int;
using ull = unsigned long long;
template <uint MD> struct ModInt {
    using M = ModInt;
    // static int MD;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint((ull)v * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    bool operator!=(const M& r) const { return v != r.v; }
    M inv() const;
    friend istream& operator>>(istream& is, M& r) { ll x; is >> x; r = M(x); return is; }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};

template<uint MD>
ModInt<MD> pow(ModInt<MD> x, ll n) {
    ModInt<MD> r = 1;
    while (n) {
        if (n & 1) r *= x;
        x *= x;
        n >>= 1;
    }
    return r;
}

template<uint MD>
ModInt<MD> ModInt<MD>::inv() const { return pow(*this, MD - 2); }
// or copy egcd and {return egcd(MD, v, 1).second;}

// if MD is from input
// this line is necessary, read later as you wish
// int ModInt::MD;

using Mint = ModInt<998244353>;
// using Mint = double;

Mint q[maxn];

void solve() {
    int n, T;
    cin >> n >> T;
    vector<int> sc(n), a(n);
    for (int &i : sc)
        cin >> i;
    for (int &i : a)
        cin >> i;
    q[0] = 1;
    Mint ans = 0;
    for (int i = 0; i < n; i++) {
        Mint w = 0;
        for (int j = 0; j <= T - a[i]; j++)
            w += q[j];
        ans += w * sc[i];
        for (int j = T - a[i]; j >= 0; j--)
            q[j + a[i]] += q[j];
    }
    vector<int> pr(n);
    pr[0] = a[0];
    for (int i = 1; i < n; i++)
        pr[i] = pr[i - 1] + a[i];
    memset(q, 0, sizeof(q));
    q[0] = 1;
    for (int i = n - 1; i >= 0; i--) {
        Mint w = 0;
        for (int j = 0; j <= T - pr[i]; j++)
            w += q[j];
        ans += w * sc[i];
        for (int j = T - a[i]; j >= 0; j--)
            q[j + a[i]] += q[j];
    }
    cout << ans << '\n';
}

int main() {
#ifdef ONPC
    freopen("../a.in", "r", stdin);
//    freopen("../a.out", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed;
    cout.precision(20);
    solve();
    cerr << "\n\nConsumed " << TIME << endl;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 5072kb

input:

5
THSAD
IIVOP
SEOOH
RGETI
YMINK

output:

0

result:

wrong answer 1st lines differ - expected: 'THISI', found: '0'