求助,10pts,关注雨
  • 板块灌水区
  • 楼主CSP400pts
  • 当前回复6
  • 已保存回复6
  • 发布时间2024/8/28 21:54
  • 上次更新2024/8/29 10:01:03
查看原帖
求助,10pts,关注雨
1331383
CSP400pts楼主2024/8/28 21:54

Problem P1042

WA code

#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e6+5;
char ch;
char s[N];
int cnt,tmp1,tmp2;
int main() {
	while(cin>>ch&&ch!='E') {
		cnt++;
		s[cnt]=ch;
	}
	if(cnt==0) {
		cout<<"0:0"<<endl<<endl<<"0:0";
		return 0;
	}
	for(int i=1; i<=cnt; i++) {
		if(s[i]=='W') tmp1++;
		if(s[i]=='L') tmp2++;
		if(tmp1>=11&&tmp1-tmp2>=2) {
			cout<<tmp1<<":"<<tmp2<<endl;
			tmp1=0;
			tmp2=0;
		}
		if(tmp2>=11&&tmp2-tmp1>=2) {
			cout<<tmp1<<":"<<tmp2<<endl;
			tmp1=0;
			tmp2=0;
		}
	}
	if(tmp1||tmp2) cout<<tmp1<<":"<<tmp2<<endl;
	tmp1=0;
	tmp2=0;
	for(int i=1; i<=cnt; i++) {
		if(s[i]=='W') tmp1++;
		if(s[i]=='L') tmp2++;
		if(tmp1>=21&&(tmp1-tmp2)>=2) {
			cout<<tmp1<<":"<<tmp2<<endl;
			tmp1=0;
			tmp2=0;
		}
		if(tmp2>=21&&(tmp2-tmp1)>=2) {
			cout<<tmp1<<":"<<tmp2<<endl;
			tmp1=0;
			tmp2=0;
		}
	}
	if(tmp1||tmp2) cout<<tmp1<<":"<<tmp2;
	return 0;
	return 0;
}
2024/8/28 21:54
加载中...