mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 17:32:00 +00:00
B - Reverse Sort
https://codeforces.com/contest/1605/submission/135155141
This commit is contained in:
parent
e23f0cd392
commit
242a1604d1
32
CodeForces/1605/B/B.cpp
Normal file
32
CodeForces/1605/B/B.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user