B. Ania and Minimizing time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ania has a large integer SS. Its decimal representation has length nn and doesn't contain any leading zeroes. Ania is allowed to change at most kk digits of SS. She wants to do it in such a way that SS still won't contain any leading zeroes and it'll be minimal possible. What integer will Ania finish with? Input The first line contains two integers nn and kk (1≤n≤2000001≤n≤200000, 0≤k≤n0≤k≤n) — the number of digits in the decimal representation of SS and the maximum allowed number of changed digits. The second line contains the integer SS. It's guaranteed that SS has exactly nn digits and doesn't contain any leading zeroes. Output Output the minimal possible value of SS which Ania can end with. Note that the resulting integer should also have nn digits. Examples input Copy 5 3 51528 output Copy 10028 input Copy 3 2 102 output Copy 100 input Copy 1 1 1 output Copy 0 Note A number has leading zeroes if it consists of at least two digits and its first digit is 00. For example, numbers 0000, 0006900069 and 01010101 have leading zeroes, while 00, 30003000 and 10101010 don't have leading zeroes. |
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
int n,m;
string s;
scanf("%d%d",&n,&m);
cin>>s;
int len=s.length();
if(m==0)
cout<<s;
else if(len==1)
{
printf("0\n");
}
else
{
int l=0;
int r=0;
while(m>l)
{
if(l==0&&r==0)
{
// printf("kk\n");
if(s[0]=='1')
{
cout<<1,r++;
}
else
{
cout<<1,r++;
l++;
}
}
else
{
if(s[r]=='0')
{
cout<<0,r++;
//printf("l =%d\n",l);
}
else if(s[r]!=0)
{
cout<<0,r++;
l++;
}
}
if(r==len)
break;
}
// cout<<l<<" "<<r<<endl;
if(r!=len)
{
for(int j=r; j<len; j++)
cout<<s[j];
}
}
cout<<endl;
return 0;
}