bananaandapple @ 2024-06-12 21:22:35
#include<bits/stdc++.h>
using namespace std;
char a1[90000];
int main()
{
long long hh=0,ds=0,pd=0;
for(int i=0;i>=0;i++){
cin>>a1[i];
if(a1[i]=='W'){
hh++;
}else if(a1[i]=='L'){
ds++;
}else if(a1[i]=='E'){
cout<<hh<<":"<<ds<<endl;
cout<<endl;
pd=0;
hh=0;
ds=0;
break;
}
pd++;
if(pd==11){
cout<<hh<<":"<<ds<<endl;
pd=0;
hh=0;
ds=0;
}
}
for(int i=0;i>=0;i++){
if(a1[i]=='W'){
hh++;
}else if(a1[i]=='L'){
ds++;
}else if(a1[i]=='E'){
cout<<hh<<":"<<ds<<endl;
cout<<endl;
break;
}
pd++;
if(pd==21){
cout<<hh<<":"<<ds<<endl;
pd=0;
hh=0;
ds=0;
}
}
return 0;
}
by MuYuMC @ 2024-06-12 21:32:15
@sb_2b 看看我的AC代码
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
int n,m;
char A[70000];
int main()
{
int i,n,sum = 0,num = 0;
char l;
i = 0;
while(1)
{
cin >> l;
if(l != 'E')
{
i++;
A[i] = l;
}
else
{
break;
}
}
n = i;
if(n == 0)
{
cout << 0 << ":" << 0 << endl;
cout << endl;
cout << 0 << ":" << 0;
}
else
{
for(i = 1;i <= n;i++)
{
if(A[i] == 'W')
{
sum++;
}
if(A[i] == 'L')
{
num++;
}
if(sum >= 11 && sum - num >= 2)
{
cout << sum << ":" << num << endl;
sum = 0;
num = 0;
}
else
{
if(num >= 11 && num - sum >= 2)
{
cout << sum << ":" << num << endl;
sum = 0;
num = 0;
}
}
}
if(sum != 0 || num != 0)
{
cout << sum << ":" << num << endl;
}
cout << endl;
sum = 0;num = 0;
for(i = 1;i <= n;i++)
{
if(A[i] == 'W')
{
sum++;
}
if(A[i] == 'L')
{
num++;
}
if(sum >= 21 && sum - num >= 2)
{
cout << sum << ":" << num << endl;
sum = 0;
num = 0;
}
else
{
if(num >= 21 && num - sum >= 2)
{
cout << sum << ":" << num << endl;
sum = 0;
num = 0;
}
}
}
if(sum != 0 || num != 0)
{
cout << sum << ":" << num << endl;
}
}
return 0;
}
by YU_Accepted @ 2024-06-15 09:40:02
AC代码:
#include <iostream>
#include <cmath>
using namespace std;
char a[100005];
int main()
{
int h = 0, y = 0;
for(int i = 1; ;i++)
{
cin >> a[i];
if(a[i] == 'W')
{
h++;
}
if(a[i] == 'L')
{
y++;
}
if(h >= 11 || y >= 11)
{
if(abs(h - y) >= 2)
{
cout << h << ":" << y << endl;
h = 0;
y = 0;
}
}
if(a[i] == 'E')
{
break;
}
}
cout << h << ":" << y << endl << endl;
h = 0;
y = 0;
for(int i = 1; ;i++)
{
if(a[i] == 'W')
{
h++;
}
if(a[i] == 'L')
{
y++;
}
if(h >= 21 || y >= 21)
{
if(abs(h - y) >= 2)
{
cout << h << ":" << y << endl;
h = 0;
y = 0;
}
}
if(a[i] == 'E')
{
break;
}
}
cout << h << ":" << y << endl;
return 0;
}
by bananaandapple @ 2024-06-15 15:07:53
@YU_Accepted 突然理解了,谢谢大佬