10438 | 2024-04-02 14:03:51 | 111 | Túlcsordulás | cpp17 | Wrong answer 70/100 | 193ms | 15540 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define BASE 256
#define BASE_INV 285156252
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 | 2004 KiB | ||||
2 | Accepted | 3ms | 2152 KiB | ||||
subtask2 | 40/40 | ||||||
3 | Accepted | 3ms | 2380 KiB | ||||
4 | Accepted | 3ms | 2588 KiB | ||||
5 | Accepted | 4ms | 2588 KiB | ||||
6 | Accepted | 3ms | 3156 KiB | ||||
7 | Accepted | 4ms | 2912 KiB | ||||
8 | Accepted | 4ms | 3112 KiB | ||||
9 | Accepted | 4ms | 3348 KiB | ||||
subtask3 | 30/30 | ||||||
10 | Accepted | 3ms | 3268 KiB | ||||
11 | Accepted | 19ms | 3920 KiB | ||||
12 | Accepted | 71ms | 7776 KiB | ||||
13 | Accepted | 74ms | 10064 KiB | ||||
14 | Accepted | 131ms | 14152 KiB | ||||
15 | Accepted | 188ms | 13868 KiB | ||||
16 | Accepted | 186ms | 13488 KiB | ||||
17 | Accepted | 182ms | 14672 KiB | ||||
subtask4 | 0/30 | ||||||
18 | Accepted | 8ms | 5000 KiB | ||||
19 | Accepted | 35ms | 15180 KiB | ||||
20 | Accepted | 64ms | 7268 KiB | ||||
21 | Accepted | 112ms | 12452 KiB | ||||
22 | Accepted | 189ms | 15300 KiB | ||||
23 | Wrong answer | 180ms | 15540 KiB | ||||
24 | Accepted | 187ms | 15040 KiB | ||||
25 | Accepted | 180ms | 14552 KiB | ||||
26 | Wrong answer | 188ms | 15436 KiB | ||||
27 | Accepted | 193ms | 15400 KiB | ||||
28 | Wrong answer | 180ms | 15396 KiB |