-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinary_minimal.cpp
More file actions
46 lines (46 loc) · 885 Bytes
/
binary_minimal.cpp
File metadata and controls
46 lines (46 loc) · 885 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n, k;
cin >> n >> k;
string s;
cin >> s;
int o = 0;
int z = 0;
int i = 0;
int c = 0;
while (i < n)
{
if (s[i] == '1')
{
c++;
}
i++;
}
if (c > k)
{
for (int j = 0; j < n; j++)
{
if (s[j] == '1' && k > 0)
{
s[j] = '0';
k--;
}
}
cout << s << endl;
}
else
{
for (int j = 0; j < (n - k); j++)
{
cout << '0';
}
cout << endl;
}
}
}