Nusrat_Ullah

CF 588 Div2 B

Sep 23rd, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int g,t,y;
  6.     string q,re;
  7.     scanf("%d %d",&t,&y);
  8.     cin>>q;
  9.     if(t==1&&y)re+='0';
  10.     else if(t==1&&!y)re+=q[0];
  11.     else for(g=0;q[g];g++){
  12.         if(!g&&y){
  13.             re+='1';
  14.             if(q[g]!='1')y--;
  15.         }
  16.         else if(y){
  17.             re+='0';
  18.             if(q[g]!='0')y--;
  19.         }
  20.         else re+=q[g];
  21.     }
  22.     cout<<re<<endl;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment