QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#663924#4322. rsraogps / 雪に咲く花guosounWA 2524ms276128kbC++171.5kb2024-10-21 18:24:372024-10-21 18:24:38

Judging History

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

  • [2024-10-21 18:24:38]
  • 评测
  • 测评结果:WA
  • 用时:2524ms
  • 内存:276128kb
  • [2024-10-21 18:24:37]
  • 提交

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<ll> 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 (ll &x : a) std::cin >> x;
  for (ll &x : b) std::cin >> x;
  for (ll &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: 2524ms
memory: 276128kb

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:

4342824024213387381
-944145338829206495
-5777725547317140976
3051854759655939423
6238897080720891333
6388725501406050755
-8139887197821258575
-5846348073730257771
5669626024392008369
-4393484242885115233
-8590493229359847932
8566808645331619273
6142830716157790661
3290453531303378686
-47450962459968...

result:

wrong answer 1st lines differ - expected: '3578099829', found: '4342824024213387381'