#define u32 unsigned
#define fo(i,x,y) for(int i = x;i <= y;++i)
#define pop __builtin_popcount
u32 b1[300010][3],b2[300010][3];
void solve(int n, int q, char *s1, char *s2, int *q_x, int *q_y, int *q_len, u32 *ans)
{
fo(i,0,n - 1) s1[i] = (s1[i] - 47) % 3,s2[i] -= 48;
fo(i,0,n - 32) fo(j,0,2) fo(k,0,31) b1[i][j] = b1[i][j] << 1 | (s1[i + k] == j);
fo(i,0,n - 32) fo(j,0,2) fo(k,0,31) b2[i][j] = b2[i][j] << 1 | (s2[i + k] == j);
fo(i,0,q - 1)
{
int x = q_x[i],y = q_y[i],l = q_len[i];
if(l == 0) continue;
int J = 0;
for(int j = 0;j + 33 <= l;j += 32)
{
ans[i] += pop(b1[x + j][0] & b2[y + j][0]);
ans[i] += pop(b1[x + j][1] & b2[y + j][1]);
ans[i] += pop(b1[x + j][2] & b2[y + j][2]);
J = j + 32;
}
fo(j,J,l - 1) ans[i] += (s1[x + j] == s2[y + j]);
}
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 335 us | 64 KB | Wrong Answer | Score: 0 | 显示更多 |
Testcase #2 | 3 s | 11 MB + 244 KB | Time Limit Exceeded | Score: 0 | 显示更多 |