Saleh127

cf 1369B

Jun 23rd, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. test
  10. {
  11.  
  12. ll n,c=-2,d=-2,e,f,i,j,k,l;
  13. string a;
  14. cin>>n;
  15. cin>>a;
  16.  
  17. for(i=0;i<n;i++)
  18. {
  19. if(a[i]=='1')
  20. {
  21. c=i;
  22. break;
  23. }
  24. }
  25. for(i=n-1;i>=0;i--)
  26. {
  27. if(a[i]=='0')
  28. {
  29. d=i;
  30. break;
  31. }
  32. }
  33. if(d<c)
  34. {
  35. cout<<a<<endl;
  36. continue;
  37. }
  38. if(c<0 || d<0)
  39. {
  40. cout<<a<<endl;
  41. continue;
  42. }
  43. for(j=0;j<c;j++)
  44. {
  45. cout<<a[j];
  46. }
  47. cout<<0;
  48. for(j=n-1;j>d;j--)
  49. {
  50. cout<<a[j];
  51. }
  52. cout<<endl;
  53.  
  54. }
  55.  
  56.  
  57. return 0;
  58. }
Add Comment
Please, Sign In to add comment