最后一个测试点没过TAT
查看原帖
最后一个测试点没过TAT
890206
black_dogoo楼主2023/10/17 23:11
#include<iostream>
#include<string>
#include<vector>

using namespace std;

class ElevenGame {
private:
    int w, l; // w与l的胜局数
    vector<pair<int, int>> games;

public:
    ElevenGame() : w(0), l(0) {}

    void GameStart(char sym) {
        if ((this->w >= 11 || this->l >= 11)&&((w-l)>1||(l-w)>1))
        {
            games.push_back(make_pair(this->w, this->l));
            this->w = 0;
            this->l = 0;
        }
        if (sym == 'W')
            this->w++;
        else if (sym == 'L')
            this->l++;
    }

    void GameLast()
    {
        games.push_back(make_pair(this->w,this->l));
    }

    void GameResult() {
        for (auto &x : this->games) {
            cout << x.first << ":" << x.second << endl;
        }
    }
};

class TwentyFirstGame {
private:
    int w, l; // w与l的胜局数
    vector<pair<int, int>> games;

public:
    TwentyFirstGame() : w(0), l(0) {}

    void GameStart(char sym) {
        if ((this->w >= 21 || this->l >= 21)&&((w-l)>1||(l-w)>1))
        {
            games.push_back(make_pair(this->w, this->l));
            this->w = 0;
            this->l = 0;
        }
        if (sym == 'W')
            this->w++;
        else if (sym == 'L')
            this->l++;
    }

    void GameLast()
    {
        games.push_back(make_pair(this->w,this->l));
    }

    void GameResult() {
        for (auto &x : this->games) {
            cout << x.first << ":" << x.second << endl;
        }
    }
};

int main() {
    string s;
    cin>>s;
    ElevenGame game1;
    TwentyFirstGame game2;
    while (1)
    {
        for (auto x : s)
        {
            if(x=='E')
            goto outside;
            game1.GameStart(x);
            game2.GameStart(x);
        }
        cin>>s;
    }
    outside:;
    game1.GameLast();
    game2.GameLast();
    game1.GameResult();
    cout<<endl;
    game2.GameResult();
    return 0;
}
2023/10/17 23:11
加载中...