60分,求调

P1042 [NOIP2003 普及组] 乒乓球

DJK227411 @ 2024-10-10 01:32:23

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long sz[2]={11,21},j1[250005],ans=0,l=0,w=0;
    while(1){
        char b;
        cin>>b;
        if(b=='E'){
            break;  
        }
        else if(b=='L'){
            j1[ans++]=0;
        }
        else if(b=='W'){
            j1[ans++]=1;   
        }
    }
    for(int k=0;k<2;k++){
        for(long long i=0;i<ans;i++){   
            l+=1-j1[i];w+=j1[i];
                if((l==sz[k]||w==sz[k])&&((max(w,l)-min(w,l))>=2)){
                cout<<w<<":"<<l<<endl;
                l=0,w=0; 
                }
        }
        cout<<w<<":"<<l<<endl;
        l=0,w=0;
        cout<<endl;
    }
    return 0;
}

|