### 题目描述

1187的基础上添加两种道具：@#

@：表示消去串中所有相同的超过3个的连续字符，其位置任意，如：33322444555555，输入：@ 1，输出：22

#：表示其插入位置的后一位将转换为与前一位相同，如：223224，输入：# 3，输出：4

### 样例输入

11112113333444445555

# 5

@ 1

3333444445555

You win!

### 代码如下

``````#include <stdio.h>
#include <string.h>
int main()
{
char num[1000];
scanf("%s",&num);
char n;
int th;
int i,j;
int sheng=0;
int len;
int countfirst;
int countn=0;
int count;
while(scanf(" %c%d",&n,&th)!=EOF)
{
if(n=='@')
{
len=strlen(num);
count=0;
for(i=1;i<len;i++)
{
if(num[i]==num[i-1])
{
count++;
if(i==len-1&&count>=2)
{
num[len-count-1]='\0';
}
}
else
{
if(count<2)count=0;
else
{
{
for(j=i-count-1;j<len-count-1;j++)
{
num[j]=num[j+count+1];
}
}
len=len-count-1;
num[len]='\0';
count=0;
i=0;
}
}

}
if(strlen(num)==0) {sheng=1;break;}
printf("%s\n\n",num);
}
else if(n=='#')
{
num[th-1]=num[th-2];
countn=0;
for(i=0;i<strlen(num);i++)
{
if(i!=0)
{
if(num[i]==num[i-1])
{
if(countn==0)
{
countn++;
countfirst=i-1;
}
countn++;
}
else
{
if(countn>=3)
{
if(th-1>=countfirst&&th-1<=countfirst+countn-1)
{
for(i=countfirst;i<strlen(num)-countn;i++)
{
num[i]=num[i+countn];
}
num[i]='\0';
}
}
countn=0;
}
}
}
if(countn>=3)
{
if(th-1>=countfirst&&th-1<=countfirst+countn-1)
{
for(i=countfirst;i<strlen(num)-countn;i++)
{
num[i]=num[i+countn];
}
num[i]='\0';
}
}
if(strlen(num)==0)
{
printf("You win!\n");
break;
}
else
printf("%s\n\n",num);
}
else
{
int len=strlen(num);
for(i=len;i>th;i--)
{
num[i]=num[i-1];
}
num[th]=n;
num[len+1]='\0';
countn=0;
for(i=0;i<strlen(num);i++)
{
if(i!=0)
{
if(num[i]==num[i-1])
{
if(countn==0)
{
countn++;
countfirst=i-1;
}
countn++;
}
else
{
if(countn>=3)
{
if(th-1>=countfirst&&th-1<=countfirst+countn-1&&n==num[countfirst])
{
for(i=countfirst;i<strlen(num)-countn;i++)
{
num[i]=num[i+countn];
}
num[i]='\0';
}
}
countn=0;
}
}
}
if(countn>=3)
{
if(th>=countfirst&&th<=countfirst+countn-1)
{
for(i=countfirst;i<strlen(num)-countn;i++)
{
num[i]=num[i+countn];
}
num[i]='\0';
}
}
if(strlen(num)==0)
{
printf("You win!\n");
break;
}
else
printf("%s\n\n",num);
}
}
if(sheng)printf("You win!\n");
return 0;
}
``````