#include<stdio.h>
#include<string.h>
int flag(char c)
{
if(c=='r')
return 1;
else if(c=='w')
return 0;
else
return 2;
}
int main()
{
char str[1000000];
int n, i=0, j=0, count[1000000], c=0, k, f, fl, max;
char p, ic;
while(str[i]=='w')
i++;
if(str[i]==str[n-1])
fl=1;
else
fl=0;
}
while(i<n)
{
if(i>0 && str[i-1]=='w')
{
while(str[i-1]=='w')
i--;
}
k=i+1;
p=str[i];
f=flag(str[i]);
while(str[i+1]=='w'||str[i+1]==str[i]||(str[i]=='w' && ((flag(str[i+1])==f)||f==0)))
{
c++;
i++;
}
count[j++]=i-k+2;
i++;
}
if(fl==1)
count[j-1]+=count[0];
max=0;
for(i=0; i<j-1; i++)
{
if((count[i]+count[i+1])>max)
max=count[i]+count[i+1];
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RyaW5nLmg+CmludCBmbGFnKGNoYXIgYykKewogICAgaWYoYz09J3InKQogICAgICAgIHJldHVybiAxOwogICAgZWxzZSBpZihjPT0ndycpCiAgICAgICAgcmV0dXJuIDA7CiAgICBlbHNlCiAgICAgICAgcmV0dXJuIDI7Cn0KaW50IG1haW4oKQp7CiAgICBjaGFyIHN0clsxMDAwMDAwXTsKICAgIGludCBuLCBpPTAsIGo9MCwgY291bnRbMTAwMDAwMF0sIGM9MCwgaywgZiwgZmwsIG1heDsKICAgIGNoYXIgcCwgaWM7CiAgICBzY2FuZigiJWQiLCAmbik7CiAgICBnZXRjaGFyKCk7CiAgICBnZXRzKHN0cik7CiAgICB3aGlsZShzdHJbaV09PSd3JykKICAgICAgICAgICAgaSsrOwogICAgICAgIGlmKHN0cltpXT09c3RyW24tMV0pCiAgICAgICAgICAgIGZsPTE7CiAgICAgICAgZWxzZQogICAgICAgICAgICBmbD0wOwogICAgfQogICAgd2hpbGUoaTxuKQogICAgewogICAgICAgIGlmKGk+MCAmJiBzdHJbaS0xXT09J3cnKQogICAgICAgIHsKICAgICAgICAgICAgd2hpbGUoc3RyW2ktMV09PSd3JykKICAgICAgICAgICAgICAgIGktLTsKICAgICAgICB9CgogICAgICAgIGs9aSsxOwogICAgICAgIHA9c3RyW2ldOwogICAgICAgIGY9ZmxhZyhzdHJbaV0pOwogICAgICAgIHdoaWxlKHN0cltpKzFdPT0ndyd8fHN0cltpKzFdPT1zdHJbaV18fChzdHJbaV09PSd3JyAmJiAoKGZsYWcoc3RyW2krMV0pPT1mKXx8Zj09MCkpKQogICAgICAgIHsKICAgICAgICAgICAgYysrOwogICAgICAgICAgICBpKys7CiAgICAgICAgfQogICAgICAgIGNvdW50W2orK109aS1rKzI7CiAgICAgICAgaSsrOwogICAgfQogICAgaWYoZmw9PTEpCiAgICAgICAgY291bnRbai0xXSs9Y291bnRbMF07CiAgICBtYXg9MDsKICAgIGZvcihpPTA7IGk8ai0xOyBpKyspCiAgICB7CiAgICAgICAgaWYoKGNvdW50W2ldK2NvdW50W2krMV0pPm1heCkKICAgICAgICAgICAgbWF4PWNvdW50W2ldK2NvdW50W2krMV07CiAgICB9CiAgICBwcmludGYoIiVkIixtYXgpOwogICAgcmV0dXJuIDA7Cn0=
prog.c: In function ‘main’:
prog.c:19:5: warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(str);
^
prog.c:16:13: warning: unused variable ‘ic’ [-Wunused-variable]
char p, ic;
^
prog.c:16:10: warning: unused variable ‘p’ [-Wunused-variable]
char p, ic;
^
prog.c:15:53: warning: unused variable ‘max’ [-Wunused-variable]
int n, i=0, j=0, count[1000000], c=0, k, f, fl, max;
^
prog.c:15:49: warning: variable ‘fl’ set but not used [-Wunused-but-set-variable]
int n, i=0, j=0, count[1000000], c=0, k, f, fl, max;
^
prog.c:15:46: warning: unused variable ‘f’ [-Wunused-variable]
int n, i=0, j=0, count[1000000], c=0, k, f, fl, max;
^
prog.c:15:43: warning: unused variable ‘k’ [-Wunused-variable]
int n, i=0, j=0, count[1000000], c=0, k, f, fl, max;
^
prog.c:15:38: warning: unused variable ‘c’ [-Wunused-variable]
int n, i=0, j=0, count[1000000], c=0, k, f, fl, max;
^
prog.c:15:22: warning: unused variable ‘count’ [-Wunused-variable]
int n, i=0, j=0, count[1000000], c=0, k, f, fl, max;
^
prog.c:15:17: warning: unused variable ‘j’ [-Wunused-variable]
int n, i=0, j=0, count[1000000], c=0, k, f, fl, max;
^
prog.c: At top level:
prog.c:27:5: error: expected identifier or ‘(’ before ‘while’
while(i<n)
^
prog.c:46:5: error: expected identifier or ‘(’ before ‘if’
if(fl==1)
^
prog.c:48:5: warning: data definition has no type or storage class [enabled by default]
max=0;
^
prog.c:48:5: warning: type defaults to ‘int’ in declaration of ‘max’ [-Wimplicit-int]
prog.c:49:5: error: expected identifier or ‘(’ before ‘for’
for(i=0; i<j-1; i++)
^
prog.c:49:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
for(i=0; i<j-1; i++)
^
prog.c:49:22: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘++’ token
for(i=0; i<j-1; i++)
^
prog.c:54:12: error: expected declaration specifiers or ‘...’ before string constant
printf("%d",max);
^
prog.c:54:17: error: expected declaration specifiers or ‘...’ before ‘max’
printf("%d",max);
^
prog.c:55:5: error: expected identifier or ‘(’ before ‘return’
return 0;
^
prog.c:56:1: error: expected identifier or ‘(’ before ‘}’ token
}
^
prog.c: In function ‘main’:
prog.c:26:5: warning: control reaches end of non-void function [-Wreturn-type]
}
^