| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Why wa???#include<stdio.h>
#include<string.h>
char a[111][111];
int n,sum,x;
int f(char b[],char c[],char d[],char e[])
{
int i;
for(i=0;i<n;i++)
{
if(i==x)
continue;
if(strstr(a[i],b)==NULL&&strstr(a[i],c)==NULL&&strstr(a[i],d)==NULL&&strstr(a[i],e)==NULL)
return 0;
}
return 1;
}
int main()
{
int i,j,k;
char b[111],c[111],d[111],e[111];
int m,len;
scanf("%d",&m);
while(m--)
{
int flag=0;
sum=100000;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",a[i]);
len=strlen(a[i]);
if(sum>len)
{
sum=len;
x=i;
}
}
j=sum-1;
int l=0;
while(j>=0&&l<=sum-1)
{
k=0;
for(i=0;i<=j;i++)
b[i]=a[x][i];
b[i]='\0';
for(i=j;i>=0;i--)
c[k++]=a[x][i];
c[k]='\0';
k=0;
for(i=l;i<=sum-1;i++)
d[k++]=a[x][i];
d[k]='\0';
k=0;
for(i=sum-1;i>=l;i--)
e[k++]=a[x][i];
e[k]='\0';
if(f(b,c,d,e))
{
flag=1;
printf("%d\n",j+1);
break;
}
j--;
l++;
}
if(flag==0)
printf("0\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator