40分,求调!

P1042 [NOIP2003 普及组] 乒乓球

wzxujiacheng__ @ 2024-10-07 20:36:56

#include<bits/stdc++.h>
using namespace std;
int f[2]={11,21},a[25*2500+10],n=0;
char tmp;
int read(){
    int ret=0,f=1;char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-')f=-f;ch=getchar();}
    while (isdigit(ch)) ret=(ret<<3)+(ret<<1)+(ch&15),ch=getchar();
    return ret*f;
}
int main(){
    while(1){
        scanf("%c",&tmp);
        if(tmp=='E')break;
        else if(tmp=='W')a[n++]=1;
        else if(tmp=='L')a[n++]=0;
    }
    for(int i=0;i<2;i++){
        int w=0,l=0;
        for(int j=0;j<n;j++){
            w+=a[j];l+=1-a[j];
            if((max(w,l)>=f[i])&&abs(w-1)>=2){
                printf("%d:%d\n",w,l);w=l=0;
            }
        }
        printf("%d:%d\n",w,l);
        printf("\n");
    }
    return 0;
}

by craftmine @ 2024-10-11 11:10:32

ye_you是让你改成abs(w-l)>=2


by wzxujiacheng__ @ 2024-10-11 16:27:52

@craftmine 知道了


by starwind24 @ 2024-10-11 22:06:18

开的药你吃了吗


上一页 |