#include <iostream> using namespace std; int main() { int n; char c[100005]; int cn[100005]; while (cin >> n && n != 0) { int h= 0; int t = 0; cin >> c; if (n % 2 != 0) { cout << -1<< endl; continue; } else { for (int i = 0; i < n; i++) { if (c[i] == 'H') { h++; } else { t++; } cn[i] = h; } if (h % 2 != 0 || t % 2 != 0) { cout << -1 << endl; continue; } int hh = 0; for (int i = 0; i < n / 2; i++) { if (c[i] == 'H') hh++; } if (hh == h / 2) { cout << 1 << "\n" << n / 2 << endl; continue; } else { cout << 2 << endl; } for (int i = 0; i < n / 2 - 1; i++) { if (cn[i + n / 2] - cn[i] == h/2) { cout << i+1 << " " << i + n / 2+1 << endl; break; } } } } return 0; }
HDU 3363 冰糖葫芦
猜你喜欢
转载自www.cnblogs.com/coegle18/p/11571648.html
今日推荐
周排行