wry0510 @ 2024-12-03 21:05:28
#include<bits/stdc++.h>
using namespace std;
int tmp,n,j,w,l;
long long a[1000005],f[1000005];
int main(){
while(1){
cin>>tmp;
if(tmp=='E') break;
else if(tmp=='W') a[n++]=1;
else if(tmp=='L') a[n++]=0;
}
for(int i=0;i<2;i++){
int w=0,l=0;
for(int j=0;j<n;j++){
w+=a[i];
l+=1-a[i];
}
cout<<'W'<<":"<<l<<endl;
cout<< endl;
}
if((max(w,l)<=f[j])&&abs(w-l)>=2){
cout<<'W'<<":"<<l<<endl;
w=l=0;
}
return 0;
}
by ycyjx @ 2024-12-07 16:24:16
数组开大了
#include<bits/stdc++.h>
using namespace std;
char s;
int a[1000001]={};
int main(){
int n=1,w=0,l=0;
while (cin>>s&&s!='E'){
if (s=='W')a[n]=1;
else if (s=='L')a[n]=2;
n++;
}
for (int i=1;i<=n;i++){
if (a[i]==1)w++;
if (a[i]==2)l++;
if (a[i]==0){
cout<<w<<":"<<l<<endl<<endl;
break;
}
if (abs(w-l)>=2){
if (w>=11||l>=11){
cout<<w<<":"<<l<<endl;
w=0;
l=0;
}
}
}
w=0;
l=0;
for (int i=1;i<=n;i++){
if (a[i]==1)w++;
if (a[i]==2)l++;
if (a[i]==0){
cout<<w<<":"<<l<<endl<<endl;
break;
}
if (abs(w-l)>=2){
if (w>=21||l>=21){
cout<<w<<":"<<l<<endl;
w=0;
l=0;
}
}
}
return 0;
}
by ycyjx @ 2024-12-07 16:24:55
不用long long