社区讨论
玄学错误......
P1203[IOI 1993 / USACO1.1] 坏掉的项链 Broken Necklace参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @mi6wk6si
- 此快照首次捕获于
- 2025/11/20 11:59 4 个月前
- 此快照最后确认于
- 2025/11/20 11:59 4 个月前
#include
#include<stdio.h>
#include
using namespace std;
int n,i,j,sum,ans,ai,bi,aii,bii;
char a,b;
string st;
int main()
{
cin>>n;
cin>>st;
ans=2;
for (i=1; i<st.size(); i++)
{
a=st[i]; ai=i; b=st[i-1]; bi=i-1; sum=2;
aii=ai; bii=bi;
while (true)
{
bi--;
if (bii==bi) break;
if (bi==0) bi=st.size()-1;
if (st[bi]!='w')
{
if (st[bi]!=b && b!='w') break;
if (st[bi]!=b && b=='w') b=st[bi];
}
sum++;
}
while (true)
{
ai++;
if (aii==ai) break;
if (ai==st.size()) ai=0;
if (st[ai]!='w')
{
if (st[ai]!=a && a!='w') break;
if (st[ai]!=a && a=='w') a=st[ai];
}
sum++;
}
ans=max(ans,sum);
}
cout<<ans<<endl;
}
回复
共 2 条回复,欢迎继续交流。
正在加载回复...