-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathdinti.cpp
48 lines (42 loc) · 868 Bytes
/
dinti.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# include <fstream>
# include <algorithm>
# define NR 2000005
# define lb 25
using namespace std;
ifstream f("dinti.in");
ofstream g("dinti.out");
int i,j,n,m,x,y,L,nr;
bool ap[NR];
char s[NR], B[lb];
void dinamica ()
{
int cs=(1<<L)-1;
for (int i=cs; i>=1; --i) {
if (ap[i])
{
for (j=0; j<L; ++j)
if (i & (1<<j)) ap[i - (1<<j)]=1;
}
}
}
int main ()
{
f>>n>>m>>L; f.get();
f.getline (s+1, NR);
for (i=1; i<=L; ++i)
nr=nr*2 + (1 - (s[i]-'0'));
ap[nr]=1;
for (i=L+1; i<=n; ++i) {
nr=nr-(1<<(L-1)) * (1 - (s[i-L]-'0'));
nr=nr*2 + 1 - (s[i]-'0');
ap[nr]=1;
}
dinamica ();
for (i=1; i<=m; ++i) {
f.getline (B+1, lb); nr=0;
for (j=1; j<=L; ++j)
nr=nr*2 + B[j]-'0';
g<<ap[nr]<<"\n";
}
return 0;
}