终于过了这sb题了。
当初我连这道题都A不了(╯▔皿▔)╯
代码
#include <cstdio> #include <iostream> #define N 1000001 #define abs(x) ((x) < 0 ? -(x) : (x)) int n = 1, sum1, sum2; char s[N]; int main() { int i; while(std::cin >> s[n]) if(s[n] == 'E') break; else n++; n--; for(i = 1; i <= n; i++) { s[i] == 'W' ? sum1++ : sum2++; if((sum1 >= 11 && abs(sum1 - sum2) >= 2) || (sum2 >= 11 && abs(sum1 - sum2) >= 2)) { printf("%d:%d ", sum1, sum2); sum1 = sum2 = 0; } } printf("%d:%d ", sum1, sum2); sum1 = sum2 = 0; puts(""); for(i = 1; i <= n; i++) { s[i] == 'W' ? sum1++ : sum2++; if((sum1 >= 21 && abs(sum1 - sum2) >= 2) || (sum2 >= 21 && abs(sum1 - sum2) >= 2)) { printf("%d:%d ", sum1, sum2); sum1 = sum2 = 0; } } printf("%d:%d ", sum1, sum2); return 0; }