提交记录 27854
提交时间 |
评测时间 |
2025-01-28 02:46:22 |
2025-01-28 02:46:25 |
//r1
#include <immintrin.h>
#include <string.h>
#include <cstdint>
#pragma GCC target("avx2")
inline void preprocess(char* s, int n) {
for (int i = 0; i < n; ++i) {
s[i] = '0' + ((s[i] - '0' + 2) % 3); // 正确映射
}
}
static inline void process_blocks(int blocks, const char** p1, const char** p2, unsigned* sum) {
for (int i = 0; i < blocks; ++i) {
__m256i a1 = _mm256_loadu_si256((const __m256i*)(*p1));
__m256i a2 = _mm256_loadu_si256((const __m256i*)(*p2));
__m256i b1 = _mm256_loadu_si256((const __m256i*)(*p1 + 32));
__m256i b2 = _mm256_loadu_si256((const __m256i*)(*p2 + 32));
__m256i cmp1 = _mm256_cmpeq_epi8(a1, a2);
__m256i cmp2 = _mm256_cmpeq_epi8(b1, b2);
uint64_t mask = (uint64_t)_mm256_movemask_epi8(cmp2) << 32
| _mm256_movemask_epi8(cmp1);
*sum += __builtin_popcountll(mask);
*p1 += 64;
*p2 += 64;
}
}
void solve(int n, int q, char* s1, char* s2, int* q_x, int* q_y, int* q_len, unsigned* ans) {
preprocess(s1, n);
for (int k = 0; k < q; ++k) {
const char* p1 = s1 + q_x[k];
const char* p2 = s2 + q_y[k];
unsigned len = q_len[k];
unsigned sum = 0;
while (len >= 64) {
int blocks = len / 64;
if (blocks > 255) blocks = 255;
process_blocks(blocks, &p1, &p2, &sum);
len -= blocks * 64;
}
for (unsigned i = 0; i < len; ++i) {
sum += (p1[i] == p2[i]);
}
ans[k] = sum;
}
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 176.82 us | 40 KB | Wrong Answer | Score: 0 | 显示更多 |
Testcase #2 | 1.116 s | 5 MB + 176 KB | Wrong Answer | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2025-04-05 08:53:37 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠