测试结果1: 通过本测试点|有效耗时78ms
测试结果2: 通过本测试点|有效耗时47ms
测试结果3: 通过本测试点|有效耗时47ms
测试结果4: 通过本测试点|有效耗时47ms
测试结果5: 选手程序运行超过时限
测试结果6: 通过本测试点|有效耗时47ms
测试结果7: 通过本测试点|有效耗时47ms
测试结果8: 通过本测试点|有效耗时46ms
测试结果9: 通过本测试点|有效耗时47ms
测试结果10: 通过本测试点|有效耗时47ms
#include <iostream>
using namespace std;
void changeq(int end,int leng,char a[])
{
int i,j;
for (i=0,j=end;i<j;i++,j--)
swap(a[i],a[j]);
for (i=end+1;i<leng;i++)
a[i]=a[i+1];
return;
}
void changeh(int beg,int leng,char a[])
{
int i,j;
for (i=beg,j=leng;i<j;i++,j--)
swap(a[i],a[j]);
for (i=beg-1;i<leng;i++)
a[i]=a[i+1];
return;
}
int main ()
{
char a[26],leave[26];
int s,leng;
int i,j;
cin.getline(a,26);
leng=strlen(a);
cin>>s;
for (i=0;i<s;i++)
cin>>leave[i];
for (i=0;i<leng;i++)
cout<<a[i];
if (s>=1)
cout<<endl;
for (i=0;i<s;i++)
{
for (j=0;j<leng;j++)
if (leave[i]==a[j])
break;
if (j<=leng-1-j)
changeq(j-1,leng-1,a);
else
changeh(j+1,leng-1,a);
leng--;
for (j=0;j<leng;j++)
cout<<a[j];
if (i!=s-1)
cout<<endl;
}
return 0;
}
为何超时????