就是倒数读取WL那里,用if(c=='L')是可以通过的,可是改成else就不行,前面设置跳过空字符了的啊,测试案例也和答案一样的,就很奇怪
#include <iostream>
#include <algorithm>
#include <cstring>
#define MAX_N 62521
using namespace std;
char a[MAX_N];
void solve()
{ int score1 = 0, score2 = 0;
for(int i = 0; i < strlen(a); i++) {
if(a[i] == 'W') score1++;
else score2++;
if(max(score1, score2) >= 11 && abs(score1 - score2) >= 2) {
cout<<score1<<":"<<score2<<endl;
score1 = score2 = 0;
}
}
cout<<score1<<":"<<score2<<endl;
cout<<endl;
score1 = score2 = 0;
for(int i = 0; i < strlen(a); i++) {
if(a[i] == 'W') score1++;
else score2++;
if(max(score1, score2) >= 21 && abs(score1 - score2) >= 2) {
cout<<score1<<":"<<score2<<endl;
score1 = score2 = 0;
}
}
cout<<score1<<":"<<score2<<endl;
cout<<endl;
}
int main()
{
int i = 0;
while(1) {
char c = getchar();
if(c == 'E') break;
if(c == '\n' || c == '\t' || c == 32 || c == '\0') continue;
if(c == 'W') a[i++] = c;
else a[i++] = c;
}
solve();
return 0;
}