10439 | 2024-04-02 14:05:04 | 111 | Túlcsordulás | cpp17 | Wrong answer 70/100 | 193ms | 15112 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define BASE 64
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin>>N;
string A,B;
cin>>A>>B;
for(char&c:B){
c='0'+'1'-c;
}
vector<int>p(N+1,1),ha(N+1),hb(N+1);
for(int i=0;i<N;i++){
p[i+1]=p[i]*BASE%MOD;
ha[i+1]=(ha[i]*BASE+A[i])%MOD;
hb[i+1]=(hb[i]*BASE+B[i])%MOD;
}
int Q;
cin>>Q;
while(Q--){
int x,y,L;
cin>>x>>y>>L;
int l=0,h=L;
while(l<h){
int m=(l+h)/2;
if((ha[x+m+1]-ha[x]*p[m+1]+MOD*MOD)%MOD==(hb[y+m+1]-hb[y]*p[m+1]+MOD*MOD)%MOD){
l=m+1;
}
else{
h=m;
}
}
cout<<(h==L||A[x+h]=='0'?1:0)<<' ';
}
cout<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1832 KiB | ||||
2 | Accepted | 3ms | 2056 KiB | ||||
subtask2 | 40/40 | ||||||
3 | Accepted | 3ms | 2228 KiB | ||||
4 | Accepted | 3ms | 2468 KiB | ||||
5 | Accepted | 4ms | 2680 KiB | ||||
6 | Accepted | 3ms | 2972 KiB | ||||
7 | Accepted | 4ms | 3068 KiB | ||||
8 | Accepted | 4ms | 3052 KiB | ||||
9 | Accepted | 4ms | 3048 KiB | ||||
subtask3 | 30/30 | ||||||
10 | Accepted | 2ms | 2840 KiB | ||||
11 | Accepted | 19ms | 3796 KiB | ||||
12 | Accepted | 70ms | 7452 KiB | ||||
13 | Accepted | 71ms | 9632 KiB | ||||
14 | Accepted | 129ms | 13716 KiB | ||||
15 | Accepted | 192ms | 13408 KiB | ||||
16 | Accepted | 193ms | 12944 KiB | ||||
17 | Accepted | 182ms | 14136 KiB | ||||
subtask4 | 0/30 | ||||||
18 | Accepted | 8ms | 4240 KiB | ||||
19 | Accepted | 37ms | 14396 KiB | ||||
20 | Accepted | 65ms | 6684 KiB | ||||
21 | Accepted | 111ms | 12028 KiB | ||||
22 | Accepted | 190ms | 14712 KiB | ||||
23 | Wrong answer | 181ms | 15028 KiB | ||||
24 | Accepted | 189ms | 14660 KiB | ||||
25 | Accepted | 182ms | 14168 KiB | ||||
26 | Wrong answer | 187ms | 15044 KiB | ||||
27 | Accepted | 190ms | 15008 KiB | ||||
28 | Wrong answer | 180ms | 15112 KiB |