criis @ 2024-09-25 14:10:18
#include<bits/stdc++.h>
using namespace std;
char score[30];
long long s[10][2501];
long long i,j;
int main(){
int m=1;
while(scanf("%s",score))
{
int n=0,str=strlen(score);
while(n<=str&&score[n]!='E')
{
if(score[n]=='W')
{
s[1][i]++;
s[2][j]++;
}
else
{
s[3][i]++;
s[4][j]++;
}
if(m%11==0) i++;
if(m%21==0) j++;
m++,n++;
}
}
int x=0;
while(x<=i)
{
cout<<s[1][x]<<":"<<s[3][x]<<endl;
x++;
}
cout<<endl;
x=0;
while(x<=j)
{
cout<<s[2][x]<<":"<<s[4][x]<<endl;
x++;
}
return 0;
}
by MinLand @ 2024-09-25 14:15:42
给你一个参考的,你自己看看。
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
char ch;
int w11, l11, w21, l21;
void f11(char);
void f21(char);
queue<pair<int, int>> q1, q2;
int main() {
//freopen("maker.exe", "w", stdout);
while (true) {
cin >> ch;
f11(ch);
f21(ch);
if (ch == 'E')
break;
}
while (q1.size()) {
printf("%d:%d\n", q1.front().first, q1.front().second);
q1.pop();
}
putchar('\n');
while (q2.size()) {
printf("%d:%d\n", q2.front().first, q2.front().second);
q2.pop();
}
return 0;
}
void f11(char c) {
if (c == 'W')w11++;
if (c == 'L')l11++;
if (abs(w11 - l11) >= 2) {
if (w11 >= 11 or l11 >= 11) {
q1.push({w11, l11});
w11 = 0, l11 = 0;
return;
}
}
if (c == 'E')
q1.push({w11, l11});
}
void f21(char c) {
if (c == 'W')w21++;
if (c == 'L')l21++;
if (abs(w21 - l21) >= 2) {
if (w21 >= 21 or l21 >= 21) {
q2.push({w21, l21});
w21 = 0, l21 = 0;
return;
}
}
if (c == 'E')
q2.push({w21, l21});
}