cyLLxGP70ytRvxZTZs3f @ 2024-09-23 21:44:57
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define inf 0x3f3f3f3f
#define sinf 0x80808080
const int N = 1e6 + 5;
string s;
int a[N], sum[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
int l = s.size();
int maxn = 0;
for (int i = 0; i < l; i++)
a[i + 1] = (s[i] == 'G' ? 1 : 0);
for (int i = 1; i <= l; i++)
sum[i] = sum[i - 1] + a[i];
for (int i = 1; i <= l; i++)
{
for (int j = i; j <= l; j++)
{
double tmp = (j - i + 1.0) / 2;
if (sum[j] - sum[i - 1] == tmp)
maxn = max(maxn, j - i + 1);
}
}
cout << maxn << '\n';
return 0;
}
by ikunTLE @ 2024-09-23 21:46:29
@cyLLxGP70ytRvxZTZs3f 逆天,
by ZMQ_Ink6556 @ 2024-09-23 22:12:52
@cyLLxGP70ytRvxZTZs3f