QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#207126#6863. OrjrjyyWA 1029ms14024kbC++201.6kb2023-10-08 09:43:262023-10-08 09:43:27

Judging History

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

  • [2023-10-08 09:43:27]
  • 评测
  • 测评结果:WA
  • 用时:1029ms
  • 内存:14024kb
  • [2023-10-08 09:43:26]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int n, q;
    std::cin >> n >> q;

    std::vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }

    std::vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> b[i];
    }

    std::vector<std::vector<std::pair<int, int>>> qry(n);
    for (int i = 0; i < q; ++i) {
        int l, r;
        std::cin >> l >> r;
        --l;
        qry[l].emplace_back(r, i);
    }

    std::vector<int> s(n + 1);
    for (int i = n - 1; i >= 0; --i) {
        s[i] = s[i + 1] + b[i];
    }

    std::vector<int> ans(q);
    for (int bit = 0; bit < 30; ++bit) {
        int fst = n;
        for (int l = n - 1; l >= 0; --l) {
            for (int i = l; i < n; ++i) {
                if ((a[l] + s[i] - s[l]) >> bit & 1) {
                    fst = std::min(fst, i);
                    break;
                }
            }

            for (auto [r, id] : qry[l]) {
                if (fst < r) {
                    ans[id] += 1 << bit;
                }
            }
        }
    }

    constexpr int P = 998244353, B = 233;

    int res = 0, coef = 1;
    for (int i = 0; i < q; ++i) {
        coef = 1ll * coef * B % P;
        res = (res + 1ll * ans[i] * coef) % P;
    }
    std::cout << res << "\n";

    // for (int i = 0; i < q; ++i) {
    //     std::cout << ans[i] << "\n";
    // }
}

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1029ms
memory: 14024kb

input:

4
40000 400000
548 4 34696904 0 7256657 310 0 253420460 0 89450757 759109 77 0 505042 382936044 1481860 986 6785 6683 477367350 88280508 0 78412 0 22978423 266 47 7409042 8 98452 437468733 0 909816 426136882 38 851 22645 387376803 0 32419 45 884 35 477851795 68713 6242 89402749 0 0 292244 605599 471...

output:

410466328
745627671
317963738
269108772

result:

wrong answer 1st lines differ - expected: '447795610', found: '410466328'