90分求助,最后一个WA了
查看原帖
90分求助,最后一个WA了
549886
CSP_zyh楼主2022/7/17 07:43
#include<iostream>
#include<cmath>
using namespace std;
char a[630000];
int main(){
    int temp=0;
    while(true){
        cin>>a[temp];
        if(a[temp]=='E'){
            break;
        }
        temp++;
    }
    if(a[0]=='E'){
        cout<<0<<":"<<0<<endl<<endl;
        cout<<0<<":"<<0;
        return 0;
    }
    temp+=1;
    bool flag=false;
    int a1=0,b1=0,a2=0,b2=0;
    for(int i=0;i<temp;i++){
        if((a1==11||b1==11)||flag==true){
            flag=true;
            if(abs(a1-b1)>=2){
                cout<<a1<<":"<<b1<<endl;
                a1=0;
                b1=0;
                flag=false;
            }
            
        }
        if(a[i]=='W'){
            a1+=1;
        }
        if(a[i]=='L'){
            b1+=1;
        }
    }
    if(a1!=0||b1!=0){
        cout<<a1<<":"<<b1<<endl;
    }
    
    cout<<endl;
    bool flag2=false;
    for(int i=0;i<temp;i++){
        if((a2==21||b2==21)||flag2==true){
            flag2=true;
            if(abs(a2-b2)>=2){
                cout<<a2<<":"<<b2<<endl;
                a2=0;
                b2=0;
                flag2=false;
            }
        }
        if(a[i]=='W'){
            a2+=1;
        }
        if(a[i]=='L'){
            b2+=1;
        }
    }
    if(a2!=0||b2!=0){
        cout<<a2<<":"<<b2;
    }
    return 0;
}
2022/7/17 07:43
加载中...