实际的情况是,usaco前面的几个题目都是熟悉语言用的,根本没有思维价值。
1 /*
2 ID: 31440461
3 LANG: C++
4 TASK: beads
5 */
6
7 #include <stdio.h>
8 #include <string.h>
9
10 char a[701];
11
12 int main()
13 {
14 freopen("beads.in", "r", stdin);
15 freopen("beads.out", "w", stdout);
16 int color = 0, curr = 0, prev = 0, w = 0, n, res = 0;
17 scanf("%d%*c", &n);
18 gets(a);
19 memcpy(a+n, a, n);
20 for (int i = 0; i < n*2 && res < n; ++i)
21 {
22 if (a[i] == 'w') ++w, ++curr;
23 else if (a[i] == color) w = 0, ++curr;
24 else
25 {
26 color = a[i];
27 if (prev+curr > res) res = prev+curr;
28 prev = curr-w; curr = w+1; w = 0;
29 }
30 }
31 if (prev+curr > res) res = prev+curr;
32 printf("%d\n", res < n ? res : n);
33 }