题解
2023-08-25 11:12:56
发布于:广东
10阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct R
{
int ll, rr;
}R1[10005],R2[10005];
int main(int argc, char* argv[])
{
string s;
int l1 = 0, l2 = 0, r1 = 0, r2 = 0;
int c1 = 0, c2 = 0;
while (cin >> s)
{
int len = s.length();
int i;
for (i = 0; i < len; ++i)
{
if (s[i] == 'W')
{
l1++; l2++;
}
else if (s[i] == 'L')
{
r1++; r2++;
}
else break;
//分差大于或者等于 2
if ((l1 >= 11 || r1 >= 11) && abs(l1 - r1) >= 2)
{
R1[c1].ll = l1;
R1[c1].rr = r1;
c1++;
l1 = r1 = 0;
}
if ((l2 >= 21 || r2 >= 21) && abs(l2 - r2) >= 2)
{
R2[c2].ll = l2;
R2[c2].rr = r2;
c2++;
l2 = r2 = 0;
}
}
if (s[i] == 'E')
{
R1[c1].ll = l1;
R1[c1].rr = r1;
c1++;
R2[c2].ll = l2;
R2[c2].rr = r2;
c2++;
break;
}
}
for (int i = 0; i < c1; ++i)
{
cout<<R1[i].ll<<':'<<R1[i].rr<<'\n';
}
cout<<'\n';
for (int i = 0; i < c2; ++i)
{
cout<<R2[i].ll<<':'<<R2[i].rr<<'\n';
}
return 0;
}
这里空空如也
有帮助,赞一个