QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#663920 | #4322. rsraogps / 雪に咲く花 | guosoun | WA | 2211ms | 252600kb | C++17 | 1.5kb | 2024-10-21 18:23:37 | 2024-10-21 18:23:38 |
Judging History
answer
#include <bits/stdc++.h>
using ll = long long;
int main() {
std::cin.tie(0)->sync_with_stdio(0);
int n, m;
std::cin >> n >> m;
std::vector<int> a(n), b(n), c(n), ca(n), cb(n), cc(n);
std::vector<std::valarray<ll>> v1(n, {0, 0}), v2(n, {0, 0});
std::vector<ll> ans(m);
std::vector<std::vector<std::pair<int, int>>> qu(n);
for (int &x : a) std::cin >> x;
for (int &x : b) std::cin >> x;
for (int &x : c) std::cin >> x;
for (int i = 0; i < m; i++) {
int l, r;
std::cin >> l >> r;
l--, r--;
qu[r].emplace_back(l, i);
}
for (int i = 0; i < n; i++) {
ca[i] = a[i], cb[i] = b[i], cc[i] = c[i];
v1[i][0] -= (a[i] * b[i] * c[i] - v1[i][1]) * (i - 1), v1[i][1] = a[i] * b[i] * c[i];
for (int j = i - 1; j >= -1; j--) {
if (j < 0 || ((ca[j] & a[i]) == ca[j] && (cb[j] | b[i]) == cb[j] && std::__gcd(cc[j], c[i]) == cc[j])) {
for (int k = j + 1; k <= i; k++) {
// if (i == 1) std::
v2[k] = k ? v1[k] + v2[k - 1] : v1[k];
}
break;
}
ca[j] &= a[i], cb[j] |= b[i], cc[j] = std::__gcd(cc[j], c[i]);
// if (i == 1) std::cerr << ca[j] << ' ' << cb[j] << ' ' << cc[j] << '\n';
v1[j][0] -= (ca[j] * cb[j] * cc[j] - v1[j][1]) * (i - 1), v1[j][1] = ca[j] * cb[j] * cc[j];
}
// if (i == 1) cpp_dump(i, v2[1]);
for (auto [l, id] : qu[i]) {
ans[id] = v2[i][0] + v2[i][1] * i;
if (l) ans[id] -= v2[l - 1][0] + v2[l - 1][1] * i;
}
}
for (ll x : ans) std::cout << x << '\n';
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 2211ms
memory: 252600kb
input:
1000000 4999998 677759 16844 194149 882507 258413 301124 335220 853562 556891 940146 265534 89372 852421 821748 453468 389493 767295 749954 967376 543995 891396 399529 837606 300380 188426 701042 209657 534843 857430 548210 681875 715389 276811 492296 717786 463046 233941 281371 641808 990695 702677...
output:
244730814625909 96795925318689 12665698542096 248674435243359 232585340329413 11027845052867 82920620242097 89940776242325 70242196923057 13446880854687 120646077752836 141664995544521 118861071485381 40783319432958 18587952708399 38127286535867 107724399485001 12851468656141 112241032799646 4953603...
result:
wrong answer 1st lines differ - expected: '3578099829', found: '244730814625909'