/* ID: lxlenovos1prog: beadslang: C ++ */# include <iostream> # include <fstream> # include <string> # include <vector> # include <string. h> # include <stdlib. h> # include <stdio. h> using namespace STD; typedef struct ring {char a; struct ring * flink; struct ring * slink;} ring; ring * sring = NULL; ring * hring = NULL; /* The first node */ring * ering = NULL;/* The End Node */INT fcout = 0; int rcout = 0; ring * bring = nu Ll; void ring_pushback (ring * r, int N) {static int I = 0; if (I = 0) {sring = r; ++ I; hring = r ;}else {sring-> slink = r; r-> flink = sring; sring = R; /* The End Node */if (I = n-1) {sring-> slink = hring; hring-> flink = sring; ering = sring ;} ++ I ;}} int get_maxresult (ring * gring) {// cout the list ring * P = NULL; char tempvalue; fcout = 1; rcout = 1; P = gring; tempvalue = p-> A; // cout <"temp1 is" <tempvalue <Endl; do {// tempvalue = p-> A; P = p-> slink; // cout <p-> A <Endl; if (p-> A = tempvalue | p-> A = 'W' | tempvalue = 'W') {If (tempvalue = 'W ') tempvalue = p-> A; If (0 = fcout) fcout = 1; ++ fcout; // cout <"1" <Endl ;} else {// cout <"2" <Endl; break ;}} while (P! = Gring); If (P = gring) goto _ cout; P = gring-> flink; tempvalue = p->; // cout <"temp2 is" <tempvalue <Endl; do {// tempvalue = p-> A; P = p-> flink; // cout <p-> A <Endl; if (p-> A = tempvalue | p-> A = 'W' | tempvalue = 'W') {If (tempvalue = 'W ') tempvalue = p-> A; If (0 = rcout) rcout = 1; ++ rcout; // cout <"1" <Endl ;} else {// cout <"2" <Endl; break ;}} while (P! = Gring); Return (rcout + fcout); _ cout: rcout = 0; fcout --; Return (rcout + fcout);} int main (void) {ofstream fout ("beads. out "); ifstream fin (" beads. in "); int N, I, result; char temp; int max = 0; ring * g = NULL; // CIN> N; Fin> N; for (I = 0; I <n; ++ I) {// CIN> temp; Fin> temp; ring * bread = new ring; bread-> A = temp; bread-> flink = NULL; bread-> slink = NULL; ring_pushback (bread, n );} // cout <"CIN is end and the result is:" <Endl; G = hring; for (I = 0; I <n; ++ I) {result = get_maxresult (g); // cout <"result is" <result <Endl; If (result> MAX) max = result; if (max> = N) {max = N; break;} G = G-> slink; // cout <G-> A <Endl ;} // cout <max <Endl; fout <Max; fout <Endl; exit (0 );}