Tiancheng123 @ 2024-08-05 18:36:14
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
char s[N];
int c1,c2;
int main()
{
char x;
scanf("%c",&x);
int cnt = 0;
while(x == 'W' || x == 'L' || x == '\n')
{
if(x != '\n') s[cnt++] = x;
scanf("%c",&x);
}
int n = strlen(s);
for(int t = 0;t < n;t++)
{
if(s[t] == 'W') c1++;
else c2++;
if((c1 >= 11 || c2 >= 11) && (abs(c1 - c2) >= 2))
{
printf("%d:%d\n",c1,c2);
c1 = 0;
c2 = 0;
}
}
printf("%d:%d\n\n",c1,c2);
c1 = 0;
c2 = 0;
for(int t = 0;t < n;t++)
{
if(s[t] == 'W') c1++;
else c2++;
if((c1 >= 21 || c2 >= 21) && (abs(c1 - c2) >= 2))
{
printf("%d:%d\n",c1,c2);
c1 = 0;
c2 = 0;
}
}
printf("%d:%d",c1,c2);
return 0;
}
by __zjr__ @ 2024-08-05 19:56:02
while(cin>>x&&x!='E') s[cnt++]=x;
by __zjr__ @ 2024-08-05 19:57:22
把输入改成这样,否则能在本地正确运行,在luogu上不行。
by __zjr__ @ 2024-08-05 19:57:52
改完就AC了
by __zjr__ @ 2024-08-05 20:57:27
@Tiancheng123