大佬求助,不知道为什么过不了

P1042 [NOIP2003 普及组] 乒乓球

chengqian233 @ 2024-10-26 19:42:02

#include<iostream>
#include<string>
#include<cmath> 
using namespace std;
int main()
{   int i=0; int w=0,l=0;
    int j=0; int r=0,t=0;
    string a; 
    cin>>a;
if(a[0]=='E')
cout<<"0:0";
while(a[i]!='E')
{
 if(a[i]=='W')
  w++;
  else
  l++;
 if((w>=11||l>=11)&&abs(w-l)>1)
 {  
    cout<<w<<":"<<l<<'\n';
    w=0;l=0;
 }  
 else if(a[i+1]=='E')
   {
     cout<<w<<":"<<l<<'\n';
   }    
    i++;
}
cout<<endl;
cout<<endl;
if(a[0]=='E')
cout<<"0:0";
while(a[j]!='E')
{
 if(a[j]=='W')
  r++;
  else
  t++;
 if((r>=21||t>=21)&&abs(r-t)>1)
 {  
    cout<<r<<":"<<t<<'\n';
    r=0;t=0;
 }  
 else if(a[j+1]=='E')
   {
     cout<<r<<":"<<t<<'\n';
   }    
    j++;
}
    return 0;
}

by flashfear @ 2024-11-08 19:23:10

给你最后一个测试点:

input:
WWWWWWWWWWWEadfadf;jadf

output:
11:0
0:0

11:0


|