#define u32 unsigned
#define fo(i,x,y) for(int i = x;i <= y;++i)
#define pop __builtin_popcount
unsigned short 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 - 15) fo(j,0,2) fo(k,0,15) b1[i][j] = b1[i][j] << 1 | (s1[i + k] == j);
fo(i,0,n - 15) fo(j,0,2) fo(k,0,15) 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];
ans[i] = 0;
if(l == 0) continue;
int J = 0,a1 = 0,a2 = 0,a3 = 0;
for(int j = 0;j + 17 <= l;j += 16)
{
a1 += pop(b1[x + j][0] & b2[y + j][0]);
a2 += pop(b1[x + j][1] & b2[y + j][1]);
a3 += pop(b1[x + j][2] & b2[y + j][2]);
J = j + 16;
}
fo(j,J,l - 1) a1 += (s1[x + j] == s2[y + j]);
ans[i] = a1 + a2 + a3;
}
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 319.24 us | 60 KB | Accepted | Score: 50 | 显示更多 |
Testcase #2 | 3 s | 7 MB + 812 KB | Time Limit Exceeded | Score: 0 | 显示更多 |