fgbhi @ 2024-10-04 23:17:57
#include<iostream>
#include<cmath>
using namespace std;
char a[2501*25+5];
int cnt=0;
int main(){
char z;
int i,n=0,m=0;
while(1)
{
cin>>z;
a[cnt++]=z;
if(z=='E') break;
}
for(i=0;i<cnt;i++)
{
if(a[i]=='W') n++;
else if(a[i]=='L') m++;
else if(a[i]=='E'&&(n!=0||m!=0))
{
cout<<n<<":"<<m<<endl;
break;
}
if(abs(n-m)>=2&&(n>=11||m>=11))
{
cout<<n<<":"<<m<<endl;
n=0;
m=0;
}
}
cout<<endl;
n=0;
m=0;
for(i=0;i<cnt;i++)
{
if(a[i]=='W') n++;
else if(a[i]=='L') m++;
else if(a[i]=='E'&&(n!=0||m!=0))
{
cout<<n<<":"<<m<<endl;
break;
}
if(abs(n-m)>=2&&(n>=21||m>=21))
{
cout<<n<<":"<<m<<endl;
n=0;
m=0;
}
}
return 0;
}
by binyage @ 2024-10-07 14:42:06
#include<bits/stdc++.h>
using namespace std;
char s[70000],ch;
int id=1,w=0,l=0;
int main()
{
while(cin>>ch)
{
if(ch=='E')
{
break;
}
else
{
s[id++]=ch;
}
}
for(int i=1;i<id;i++)
{
if(s[i]=='W')
{
w++;
}
else if(s[i]=='L')
{
l++;
}
if((w==11&&w-l>=2)||(l==11&&l-w>=2))
{
cout<<w<<":"<<l<<endl;
w=l=0;
}
else if((w>=11&&w-l>=2)||(l>=11&&l-w>=2))
{
cout<<w<<":"<<l<<endl;
w=l=0;
}
}
cout<<w<<":"<<l<<endl<<endl;
w=l=0;
for(int i=1;i<id;i++)
{
if(s[i]=='W')
{
w++;
}
else if(s[i]=='L')
{
l++;
}
if((w==21&&w-l>=2)||(l==21&&l-w>=2))
{
cout<<w<<":"<<l<<endl;
w=l=0;
}
else if((w>=21&&w-l>=2)||(l>=21&&l-w>=2))
{
cout<<w<<":"<<l<<endl;
w=l=0;
}
}
cout<<w<<":"<<l;
return 0;
}