50pts,求调!
查看原帖
50pts,求调!
1278847
Sun_ZZZ楼主2024/7/10 09:33

2、3、4、5、7测点没过

代码:

#include<iostream>
#include<cstdio> 
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
int n,a[25*2502],w,l,f[2]={11,21};
int main(){
	char temp;
	while(1){
		cin>>temp; 
		if(temp=='E'){
			break;
		}
		else if(temp=='W'){
			a[n++]=1;
		}
		else if(temp=='L'){
			a[n++]=0;
		}
	}
	for(int k=0;k<2;k++){
		w=0;l=0;
		for(int i=0;i<n;i++){
			w+=a[i];l+=(a[i]==0);
			if(w>=f[k]&&abs(w-l)>=2){
				cout<<w<<":"<<l<<endl;
				w=0;
				l=0;
			}
		}
		cout<<w<<":"<<l<<endl;
		cout<<endl;
	}
	
	return 0;
}
2024/7/10 09:33
加载中...