#include<bits/stdc++.h>
using namespace std;
char str[100000];
int f[10]={11,21};
int main(){
int cnt=0;
char cmp;
while (1)
{
cin>>cmp;
if(cmp=='E') break;
str[cnt]=cmp;
cnt++;
}
for(int x=0;x<2;x++){
int a=0,b=0;
for(int i=0;i<cnt;i++){
if(str[i]=='W') a++;
if(str[i]=='L') b++;
if(max(a,b)>=f[x]&&abs(a-b)>=2){
cout<<a<<":"<<b<<endl;
a=0,b=0;
}
}
cout<<a<<":"<<b<<endl;
if(x!=1) cout<<endl;
}
return 0;
}
- 一开始我是按照注释里面读入字符的,但是debug时候发现并没有读入,但是for循环确实也走了,看了题解之后发现用现在这种方法读入就能ac