算法: 枚举
#include<bits/stdc++.h>
using namespace std;
const int N = 710;
char s[N];
int n;
int main()
{
//freopen("beads.in","r",stdin);
//freopen("beads.out","w",stdout);
scanf("%d", &n); //getchar();
scanf("%s", s + 1);
for(int i = n + 1; i <= 2 * n; i ++) s[i] = s[i - n];//破环成链
int ans = 0;
for(int i = 1; i <= n; i++)
{
char now = s[i];
int lsum = 0, rsum = 0;
for(int j = i; j <= i + n - 1; j++)
{
if(now == 'w') lsum ++, now = s[j];
else
{
if(s[j] == now || s[j] == 'w') lsum ++;
else break;
}
}
now = s[i + n - 1];
for(int j = i + n - 1; j >= i; j--)
{
if(now == 'w') rsum ++, now = s[j];
else
{
if(s[j] == now || s[j] == 'w') rsum ++;
else break;
}
}
int res = lsum + rsum;
if(res > n) res = n;
ans = max(res, ans);
}
printf("%d", ans);
return 0;
}