mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-14 03:38:48 +00:00
33 lines
697 B
C++
33 lines
697 B
C++
#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;
|
|
}
|