提交记录 22031


用户 题目 状态 得分 用时 内存 语言 代码长度
Xiaohuba wc2017b2. 【WC2017】挑战-任务2 Compile Error 0 0 ns 0 KB C++ 2.16 KB
提交时间 评测时间
2024-07-29 20:47:06 2024-07-29 20:47:08
#include <bits/stdc++.h>

using u32 = unsigned int;
using u64 = unsigned long long;

namespace {
#define c_char_ptr const char *
#define c_int_ptr const int *
typedef u64 v4ul __attribute__((vector_size(32)));
constexpr size_t N = 3e5 + 5;
v4ul a[3][256][(N >> 6) + 1];
v4ul b[3][256][(N >> 6) + 1];
}  // namespace

void solve(int n, int q, char *s1, char *s2, int *q_x, int *q_y, int *q_len,
           unsigned *ans) {
  for (int _ = 0; _ < 3; _++)
    for (int i = 0; i < 256; i++)
      for (int j = 0; (j << 8) + i < n; j++)
#pragma GCC unroll(8)
        for (int k = (j << 8) + i; k < std::min(((j + 1) << 8) + i, n); k++)
          a[_][i][j][(k - i - (j << 8)) >> 6] |= u64(s1[k] == '0' + _)
                                                 << ((k - i) & 63);
  for (int _ = 0; _ < 3; _++)
    for (int i = 0; i < 256; i++)
      for (int j = 0; (j << 8) + i < n; j++)
#pragma GCC unroll(8)
        for (int k = (j << 8) + i; k < std::min(((j + 1) << 8) + i, n); k++)
          b[_][i][j][(k - i - (j << 8)) >> 6] |= u64(s2[k] == '0' + _)
                                                 << ((k - i) & 63);

  for (int _ = 0; _ < q; _++) {
    int x = qx[_], y = qy[_], l = qlen[_];
    auto _sum = [&](int p, int q) -> u32 {
      u32 res0 = 0, res1 = 0, res2 = 0, res3 = 0;
      for (int i = 0; i < (l >> 8); i++) {
        v4ul tmp = a[p][x & 255][i + (x >> 8)] & b[q][y & 255][i + (y >> 8)];
        res0 += __builtin_popcountll(tmp[0]);
        res1 += __builtin_popcountll(tmp[1]);
        res2 += __builtin_popcountll(tmp[2]);
        res3 += __builtin_popcountll(tmp[3]);
      }
      int _id = l >> 8, _cur = 0;
      while (_cur < ((l >> 6) & 3)) {
        u64 tmp = a[p][x & 255][_id + (x >> 8)][_cur] &
                  b[q][y & 255][_id + (y >> 8)][_cur];
        res0 += __builtin_popcountll(tmp);
        _cur++;
      }
      res0 += __builtin_popcountll(a[p][x & 255][_id + (x >> 8)][_cur] &
                                   b[q][y & 255][_id + (y >> 8)][_cur] &
                                   ((1ull << (l & 63)) - 1));
      return res0 + res1 + res2 + res3;
    };
    u32 _ans0 = _sum(0, 1), _ans1 = _sum(1, 2), _ans2 = _sum(2, 0);
    ans[_] = _ans0 + _ans1 + _ans2;
  }
}

CompilationN/AN/ACompile ErrorScore: N/A


Judge Duck Online | 评测鸭在线
Server Time: 2025-07-15 17:30:07 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠