-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1369B.cpp
57 lines (53 loc) · 1.12 KB
/
1369B.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
#include "bits/stdc++.h"
#pragma GCC optimize "trapv"
using i64 = long long int;
using namespace std;
int nxt(){int x; cin >> x; return x;}
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define inarr(a,n) for(int i = 0; i < n; ++i) cin >> a[i];
//
#ifndef ONLINE_JUDGE
#include "debug.hpp"
#else
#define print(...)
#define debug(...)
#endif
void solve(){
int n; cin >> n;
bool chk = 1;
string s; cin >> s;
for(int i = 0;i < n - 1; ++i) {
if(s[i] == '1' && s[i+1] == '0') {
chk = 0;
break;
}
}
if(chk || n == 1) {
cout << s << "\n";
return;
}
//
int i = 0, j = n - 1;
cout << "0";
while(i < n) {
if(s[i] == '0') cout << '0';
else break;
i++;
}
while(j >= 0) {
if(s[j] == '1') cout << '1';
else break;
j--;
}
cout << "\n";
}
int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int testt = 1;
cin >> testt;
for (int i = 1; i <= testt; ++i){
// cout << "Case #" << i << ": ";
solve();
}
}