20pts求助
查看原帖
20pts求助
1180206
Alex866楼主2024/6/30 09:04
#include<bits/stdc++.h>
using namespace std;
string s;
char ch;
int len,a,b;
int main(){
	while((ch=getchar())!='E'){
		if(ch!='\n'){
			s+=ch;
		}
	}
	len=strlen(s.c_str());
	for(int i=0;i<len;i++){
		if(s[i]=='W'){
			a++;
		}else{
			b++;
		}
		if((a>=11||b>=11)&&abs(a-b)>=2){
			printf("%d:%d\n",a,b);
			a=b=0;
		}
	}
	if(a+b==0){
		printf("%d:%d\n",a,b);
	}
	puts("");
	a=b=0;
	for(int i=0;i<len;i++){
		if(s[i]=='W'){
			a++;
		}else{
			b++;
		}
		if((a>=21||b>=21)&&abs(a-b)>=2){
			printf("%d:%d\n",a,b);
			a=b=0;
		}
	}
	if(a+b==0){
		printf("%d:%d\n",a,b);
	}
	return 0;
}

下了数据,在洛谷的IDE上和输出数据一样可就是不过,ε=ε=ε=(#>д<)ノ

2024/6/30 09:04
加载中...