-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA.cpp
51 lines (50 loc) · 1.05 KB
/
A.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
49
50
51
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
fastio;
long long t,n,m,i,x,j,p,ara[1005];
string a;
cin>>t;
while(t--)
{
x=0;
cin>>n>>m;
cin>>a;
for(i=0;i<n;i++)
{
if(a[i]=='1')
{
ara[x]=i;
x++;
}
}
for(i=0;i<x;i++)
{
if(i==0)
{
for(j=1;j<=min(ara[i],m);j++)
a[ara[i]-j]='1';
}
else
{
for(j=1;j<=min(m,(ara[i]-ara[i-1]-1)/2);j++)
a[ara[i]-j]='1';
}
if(i==x-1)
{
for(j=1;j<=min(m,n-1-ara[i]);j++)
a[ara[i]+j]='1';
}
else
{
for(j=1;j<=min(m,(ara[i+1]-ara[i]-1)/2);j++)
a[ara[i]+j]='1';
}
}
cout<<a<<"\n";
}
return 0;
}