0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 16:58:47 +00:00

B - Reverse Sort

https://codeforces.com/contest/1605/submission/135155141
This commit is contained in:
Baoshuo Ren 2021-11-12 23:59:00 +08:00 committed by Baoshuo Ren
parent e23f0cd392
commit 242a1604d1
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

32
CodeForces/1605/B/B.cpp Normal file
View File

@ -0,0 +1,32 @@
#include <bits/stdc++.h>
using namespace std;
int t, n;
string s;
int main() {
cin >> t;
while (t--) {
cin >> n >> s;
if (is_sorted(s.begin(), s.end())) {
cout << 0 << endl;
continue;
}
int cnt = count(s.begin(), s.end(), '1');
s = ' ' + s;
vector<int> ans;
for (int i = 1; i <= n; i++) {
if (i < n - cnt + 1 && s[i] == '1' || i >= n - cnt + 1 && s[i] == '0') {
ans.push_back(i);
}
}
cout << 1 << endl;
cout << ans.size() << ' ';
for (int i : ans) {
cout << i << ' ';
}
cout << endl;
}
return 0;
}