题解 P7919 【[Kubic] ABC】
VinstaG173 · · 题解
简单结论+构造题。
显然若
以下给出构造。由以上分析得每次操作
感觉开这个数据范围是 checker 的缘故。
Code:
#include<cstdio>
int n,x,y,t;
char s[5003];
int l[5003],r[5003];
int main()
{
scanf(" %d %s",&n,s+1);x=1,y=n;
while(x<y)
{
while(x<y&&s[x]!=s[x+1])++x;
while(y>x&&s[y]!=s[y-1])--y;
if(x==y)break;
l[++t]=++x,r[t]=--y;
}
printf("%d\n",t);
if(l[t]>r[t])r[t]=n;
for(int i=1;i<=t;++i)printf("%d %d BCA\n",l[i],r[i]);
return 0;
}