-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc.cpp
More file actions
69 lines (54 loc) · 1.14 KB
/
Copy pathc.cpp
File metadata and controls
69 lines (54 loc) · 1.14 KB
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
63
64
65
66
67
68
69
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define ll long long
#define all(v) (v).beign(), (v).end()
#define nl << "\n"
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
void solve() {
int n; cin >> n;
string s; cin >> s;
for (int i = 0; i < s.size(); i++){
if (s.substr(i, 3) == "101"){
cout << "NO" nl;
return;
}
}
if (s.substr(0,2) == "01"){
cout << "NO" nl;
return;
}
if (s.substr(s.size() - 2, 2) == "10"){
cout << "NO" nl;
return;
}
vec<int> v(n,0);
for (int i = 0; i < s.size();i++){
v[i] = i+ 1;
}
int i = 0;
while ( i < v.size()){
if ((i < v.size() - 1) && s[i] == '0' && s[i + 1] =='0'){
int tmp = v[i];
v[i] = v[i + 1];
v[i + 1] = tmp;
}
i++;
}
cout << "YES" nl;
for (int a: v){
cout << a << " ";
}
cout nl;
}
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
int tc = 1;
cin >> tc;
for (int t = 1; t <= tc; t++) {
// cout << "Case #" << t << ": ";
solve();
}
}