#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
if (s == string(n, 'F')) {
cout << n << endl;
for (int i = 0; i < n; i++) {
cout << i << endl;
}
return 0;
}
int l = 0, r = n - 1;
while (s[l] == 'F') l++;
while (s[r] == 'F') r--;
string str = s;
int low = 0, high = 0;
for (int i = l + 1; i <= r; i++) {
if (s[i] == 'F') s[i] = s[i - 1];
if (s[i] == s[i - 1]) high++;
}
s = str;
for (int i = l + 1; i <= r; i++) {
if (s[i] == 'F') {
if (s[i - 1] == 'B') s[i] = 'E';
else s[i] = 'B';
}
if (s[i] == s[i - 1]) low++;
}
int num = l + n - 1 - r, d = 2;
if (num != 0) high += num, d = 1;
cout << (high - low) / d + 1 << endl;
for (int i = low; i <= high; i += d) {
cout << i << endl;
}
return 0;
}
4993. FEB
最新推荐文章于 2024-09-11 00:16:09 发布