1tianjiahao @ 2024-07-10 14:12:23
#include<bits/stdc++.h>
using namespace std;
char c,ch[70000];
int w_11=0,l_11=0,w_21=0,l_21=0;
int len=-1;
int main()
{
c=getchar();
while(c!='E')
{
if(c!='\n') ch[++len]=c;
c=getchar();
}
++len;
for(int i=0;i<len;++i)
{
if(ch[i]=='W') ++w_11;
else ++l_11;
if(w_11>=11&&abs(w_11-l_11)>=2||l_11>=11&&abs(w_11-l_11)>=2)
{
printf("%d:%d\n",w_11,l_11);
w_11=0;l_11=0;
}
}
printf("%d:%d\n\n",w_11,l_11);
for(int i=0;i<len;++i)
{
if(ch[i]=='W') ++w_21;
else ++l_21;
if(w_21>=21&&abs(w_21-l_21)>=2||l_21>=21&&abs(w_21-l_21)>=2)
{
printf("%d:%d\n",w_21,l_21);
w_21=0;l_21=0;
}
}
printf("%d:%d\n",w_21,l_21);
return 0;
}
by Juan2012 @ 2024-07-10 14:24:26
#include <bits/stdc++.h>
using namespace std;
char x;
const int N=1e6+10;
long long ying,shu,sf[N][3],sl=1,sf2[N][3],sl2=1,ying2,shu2;
int main(){
ying=0,shu=0;
while(true){
cin>>x;
if(x=='E') break;
if((ying>=11 || shu>=11) && abs(ying-shu)>=2) sf[sl][1]=ying,sf[sl][2]=shu,sl++,ying=0,shu=0;
if((ying2>=21 || shu2>=21) && abs(ying2-shu2)>=2) sf2[sl2][1]=ying2,sf2[sl2][2]=shu2,sl2++,ying2=0,shu2=0;
if(x=='W') ying++,ying2++;
if(x=='L') shu++,shu2++;
}
sf[sl][1]=ying,sf[sl][2]=shu,sf2[sl2][1]=ying2,sf2[sl2][2]=shu2;
for(int i=1;i<=sl;i++) cout<<sf[i][1]<<":"<<sf[i][2]<<endl;
if((shu>=11 || ying>=11) && abs(shu-ying)>=2) cout<<0<<":"<<0<<endl;
cout<<endl;
for(int i=1;i<=sl2;i++) cout<<sf2[i][1]<<":"<<sf2[i][2]<<endl;
if((shu2>=21 || ying2>=21) && abs(shu2-ying2)>=2) cout<<0<<":"<<0<<endl;
return 0;
}
@1tianjiahao 我的屎山代码,可以看一下
by a18981826590 @ 2024-07-10 14:26:13
@1tianjiahao
#include<bits/stdc++.h>
using namespace std;
int win[62510],l,w;
int main(){
char s;
for(int i=1;cin>>s&&s!='E';i++){
if(s=='W') win[i]=1;
else win[i]=2;
}
for(int i=1;;i++){
if(win[i]==1) w++;
if(win[i]==2) l++;
if(win[i]==0){
cout<<w<<":"<<l<<endl<<endl;
break;
}
if(w-l>=2||l-w>=2){
if(w>=11||l>=11){
cout<<w<<":"<<l<<endl;
w=0;
l=0;
}
}
}
w=0;
l=0;
for(int i=1;;i++){
if(win[i]==1) w++;
if(win[i]==2) l++;
if(win[i]==0){
cout<<w<<":"<<l;
break;
}
if(w-l>=2||l-w>=2){
if(w>=21||l>=21){
cout<<w<<":"<<l<<endl;
w=0;
l=0;
}
}
}
return 0;
}
by 1tianjiahao @ 2024-07-10 14:26:27
@Juan2012 谢谢
by 1tianjiahao @ 2024-07-10 14:29:12
@a18981826590 谢谢,OK了
by 1tianjiahao @ 2024-07-10 16:20:49
@a18981826590 谢谢