标签:bit turn namespace pen cout freopen beads ret i++
/*
ID:marco
LANG:C++
TASK:beads
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
freopen("beads.in","r",stdin);
freopen("beads.out","w",stdout);
char s[700],c=0;
int n,i,a=0,b=0,w=0,ans=0;
cin>>n>>s;
memcpy(s+n,s,n);
for (i=0;i<n<<1;i++)
if (s[i]==‘w‘) b++,w++;
else if (s[i]==c) b++,w=0;
else
{
if (a+b>ans) ans=a+b;
a=b-w;b=w+1;w=0;c=s[i];
}
if (a+b>ans) ans=a+b;
cout<<(ans>n?n:ans)<<endl;
return 0;
}
标签:bit turn namespace pen cout freopen beads ret i++
原文地址:http://www.cnblogs.com/D-AngeloRussell/p/6516210.html