30求助,悬关
查看原帖
30求助,悬关
1043009
LGZX楼主2024/9/29 18:26
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void) {
    string inp;
    vector<char> res;
    while (cin >> inp) {
        for (char c : inp) {
            if (c == 'E') {
                break;
            }
            res.push_back(c);
        }
        if (inp.back() == 'E') {
            break;
        }
    }
    int s11_h = 0, s11_o = 0;
    int s21_h = 0, s21_o = 0; 
    vector<string> r11;
    vector<string> r21;
    for (char r : res) {
        if (r == 'W') {
            s11_h++;
            s21_h++;
        }
        else if (r == 'L') {
            s11_o++;
            s21_o++;
        }
        if (s11_h >= 11 && s11_h - s11_o >= 2) {
            r11.push_back(to_string(s11_h) + ":" + to_string(s11_o));
            s11_h = 0;
            s11_o = 0;
        }
        if (s21_h >= 21 && s21_h - s21_o >= 2) {
            r21.push_back(to_string(s21_h) + ":" + to_string(s21_o));
            s21_h = 0;
            s21_o = 0;
        }
    }
    if (s11_h > 0 || s11_o > 0) {
        r11.push_back(to_string(s11_h) + ":" + to_string(s11_o));
    }
    if (s21_h > 0 || s21_o > 0) {
        r21.push_back(to_string(s21_h) + ":" + to_string(s21_o));
    }
    for (const auto& score : r11) {
        cout << score << endl;
    }
    cout << endl;
    for (const auto& score : r21) {
        cout << score << endl;
    }
    return 0;
}

2024/9/29 18:26
加载中...