20pts求调玄关

P1042 [NOIP2003 普及组] 乒乓球

Tiancheng123 @ 2024-08-05 17:03:06

#include <bits/stdc++.h>
using namespace std;
char s[62535];
int c1,c2;
int main()
{
    char x;
    scanf("%c",&x);
    int cnt = 0;
    while(x == 'W' || x == 'L' || x == '\n')
    {
        if(x != '\n') s[cnt++] = x;
        scanf("%c",&x);
    }
    int n = strlen(s);
    for(int t = 0;t < n;t++)
    {
        if(s[t] == 'W') c1++;
        else c2++;
        if((c1 >= 11 || c2 >= 11) && (abs(c1 - c2) >= 2))
        {
            printf("%d:%d\n",max(c1,c2),min(c1,c2));
            c1 = 0;
            c2 = 0;
        }
    }
    printf("%d:%d\n\n",max(c1,c2),min(c1,c2));
    c1 = 0;
    c2 = 0;
    for(int t = 0;t < n;t++)
    {
        if(s[t] == 'W') c1++;
        else c2++;
        if((c1 >= 21 || c2 >= 21) && (abs(c1 - c2) >= 2))
        {
            printf("%d:%d\n",max(c1,c2),min(c1,c2));
            c1 = 0;
            c2 = 0;
        }
    }
    printf("%d:%d",max(c1,c2),min(c1,c2));
    return 0;
}

|