QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#207112 | #6863. Or | jrjyy | WA | 913ms | 13960kb | C++20 | 1.6kb | 2023-10-08 09:35:26 | 2023-10-08 09:35:26 |
Judging History
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 < 29; ++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: 913ms
memory: 13960kb
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:
217891846 916653755 346182091 652025396
result:
wrong answer 1st lines differ - expected: '447795610', found: '217891846'