样例过了,但是有4个RE,6个WA

P1042 [NOIP2003 普及组] 乒乓球

daweli @ 2024-09-19 13:14:32

#include<bits/stdc++.h>
using namespace std;
string s;
char c;
int x,y,x2,y2,num,len;
int main(){
    while(cin>>c&&c!='E')
        s[num++]=c;
    len=num;
    num=0;
    for(int i=0;i<len;i++){
        if(s[i]=='W')
            x++;
        else y++;
        if((x>=11||y>=11)&&abs(x-y)>=2||i==len-1){
            cout<<x<<':'<<y<<endl;
            x=0;
            y=0;
        }
    }
    cout<<endl<<endl;
    for(int i=0;i<len;i++){
        if(s[i]=='W')
            x2++;
        else y2++;
        //cout<<x2<<' '<<y2<<endl;
        if(((x2>=21||y2>=21)&&abs(x2-y2)>=2)||i==len-1){
            cout<<x2<<':'<<y2<<endl;
            x2=0;
            y2=0;
        }
    }
    return 0;
}

|