40分求助
查看原帖
40分求助
463913
tmcz202070101楼主2024/4/27 18:46
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
int main()
{
	int a[100000],w,l,n=0,f[2]={11,21};
	char shuru;
	while(1)
	{
		cin>>shuru;
		if(shuru=='E') break;
		else if(shuru=='W') a[n++]=1;
		else if(shuru=='L') a[n++]=0;
	}
	for(int k=0;k<2;k++){
		int w=0,l=0;
		for(int i=0;i<n;i++)
		{
			w+=a[i];l+=1-a[i];
			if((max(w,l)>=f[k]) && abs(w-1)>=2)
			{
				cout<<w<<":"<<l<<endl;
				w=l=0;
			}
		}
		cout<<w<<":"<<l<<endl;
		cout<<endl;
	}
	return 0;
}
2024/4/27 18:46
加载中...