2 3 4 5没过,真不知道为什么了

P1042 [NOIP2003 普及组] 乒乓球

a2123 @ 2024-12-15 13:57:24

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    char win[62525];
    int i,m=0,n=0;
    for (i = 0;;i++)
    {
        cin >> win[i];
        if(win[i] == 'E')
        {
            break;
        }
    }
    for (i = 0;win[i] != 'E';)
    {   
        m = 0;
        n = 0;
        while ((m < 11 && n < 11) || ((m >= 11 || n >= 11) && abs(m - n) <= 2))
        {
            if (win[i] == 'W')
                m++;
            else if (win[i] == 'L')
                n++;
            i++;
            if (win[i] == 'E')
                break;
        }
            cout << m << ':' << n<<endl;
    }
    if (((m >= 11 || n >= 11) && abs(m - n) >= 2)||(m==0&&n==0))
    {
        cout << 0 << ':' << 0 << endl;
    }
    cout << '\n';
    for (i = 0;win[i] != 'E';)
    {
        m = 0;
        n = 0;
        while ((m < 21 && n < 21) || ( (m >= 21 || n >= 21) && abs(m - n) <= 2))
        {
            if (win[i] == 'W')
                m++;
            else if (win[i] == 'L')
                n++;
            i++;
            if (win[i] == 'E')
                break;
        }
        cout << m << ':' << n << endl;
    }
    if (((m >= 21 || n >= 21) && abs(m - n) >= 2) || (m == 0 && n == 0))
    {
        cout << 0 << ':' << 0 << endl;
    }
    cout << '\n';
    return 0;
}

by __assassin_ @ 2024-12-15 15:21:27

@a2123 将 20 行和 41 行的 abs(m-n) \le 2 改成 abs(m-n) < 2


by __assassin_ @ 2024-12-15 15:21:57

@a2123 求关


|