求助,10分??
查看原帖
求助,10分??
1011989
FreshC楼主2023/10/11 20:44

求问大佬,自我感觉逻辑没问题,为什么只有一个测试点AC呢

#include <iostream>
using namespace std;
int main()
{
    int size = 62500;
    char* arr = new char[size];

    int i = 0, j = 0, k = 0;

    while (1)
    {
        cin >> arr[i];
        if (arr[i] == 'E')
        {
            break;
        } 

        i++;
    }

    int my_score1 = 0, your_score1 = 0;
    int my_bound1 = 0, your_bound1 = 0;
    int my_score2 = 0, your_score2 = 0;
    int my_bound2 = 0, your_bound2 = 0;

    while (1) {
        char score = arr[j];

        j++;

        if (score == 'W') {
            my_score1++;
            if (my_score1 == 11 || ((my_score1 > 11) && (my_score1 - your_score1 == 2))) {
                my_bound1++;
                cout << my_score1 << ":" << your_score1 << endl;
                my_score1 = 0;
                your_score1 = 0;
            }
        }
        if (score == 'L') {
            your_score1++;
            if (your_score1 == 11 || ((your_score1 > 11) && (your_score1 - my_score1 == 2))) {
                your_bound1++;
                cout << my_score1 << ":" << your_score1 << endl;
                your_score1 = 0;
                my_score1 = 0;
            }
        }
        if (score == 'E' && ((my_score1 != 0) || (your_score1 != 0))) {
            cout << my_score1 << ":" << your_score1 << endl;
            break;
        }
        if (score == 'E' && my_score1 == 0 && my_score1 == 0) {
            break;
        }
    }

    cout << my_bound1 << ":" << your_bound1 << endl << endl;

    while (1) {
        char score = arr[k];

        k++;

        if (score == 'W') {
            my_score2++;
            if (my_score2 == 21 || ((my_score2 > 21) && (my_score2 - your_score2 == 2))) {
                my_bound2++;
                cout << my_score2 << ":" << your_score2 << endl;
                my_score2 = 0;
                your_score2 = 0;
            }
        }
        if (score == 'L') {
            your_score2++;
            if (your_score2 == 21 || ((your_score2 > 21) && (your_score2 - my_score2 == 2))) {
                your_bound2++;
                cout << my_score2 << ":" << your_score2 << endl;
                your_score2 = 0;
                my_score2 = 0;
            }
        }
        if (score == 'E' && ((my_score2 != 0) || (your_score2 != 0))) {
            cout << my_score2 << ":" << your_score2 << endl;
            break;
        }

        if (score == 'E' && my_score2 == 0 && my_score2 == 0) {
            break;
    }
    }

    cout << my_bound2 << ":" << your_bound2 << endl;
    delete[] arr;
    return 0;
}
2023/10/11 20:44
加载中...