-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1369B AccurateLee.cpp
63 lines (56 loc) · 1.12 KB
/
1369B AccurateLee.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
52
53
54
55
56
57
58
59
60
61
62
/*
author : MishkatIT
created : Friday 2022-10-28-02.52.24
problem : 1369 B. AccurateLee
*/
#include<iostream>
//#include<deque>
#include<string>
#include<algorithm>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
fio;
int t;
cin >> t;
st:
while(t--)
{
long long n;
cin >> n;
string str;
cin >> str;
if(n == 1)
{
cout << str;
cout << '\n'; // this imposter??!!
goto st;
}
long long cnt = n;
for(int i=0; i<n; i++)
{
if(str[i] == '0')
{
cout << '0';
cnt--;
}
else break;
}
string s;
reverse(str.begin(), str.end());
for(int i=0; i<n; i++)
{
if(str[i] == '1')
{
s.push_back('1');
cnt--;
}
else break;
}
if((long long) cnt != 0 )
s.insert(s.begin(), '0');
cout << s << '\n';
}
return 0;
}