/*
LANG: C
ID: zqynux11
PROG: beads
*/
#include <stdio.h>
#include <string.h>
char ball[701];
int main(void)
{
int max = 0;
int a = 0, b = 0, w = 0; /* */
int i, n;
char ch = '\0';
freopen("beads.in", "r", stdin);
freopen("beads.out", "w", stdout);
scanf("%d\n", &n);
gets(ball);
memmove(ball + n, ball, sizeof(char)*n);
for(i = 0; i < 2 * n && max < n; i++){
if(ball[i] == 'w'){
w++;
b++;
}else if(ball[i] != ch){
ch = ball[i];
if(a + b > max){
max = a + b;
}
a = b - w;
b = w + 1;
w = 0;
}else{
w = 0;
b++;
}
}
if(a + b > max){ /* 之前没考虑到rrr这类只有一种珠子的一些特殊情况 */
max = a + b;
}
printf("%d\n", max > n ? n : max);
return 0;
}
重做 USACO 1.1 黑色星期五
最新推荐文章于 2024-10-18 14:56:07 发布