1.链接地址:
http://bailian.openjudge.cn/practice/1226/
http://poj.org/problem?id=1226
2.题目:
3.思路:
4.代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string.h>
using namespace std;
const int NUM = ;
char strs[NUM][NUM + ];
int main()
{
//freopen("F:\\input.txt","r",stdin);
int i,j,k; int t;
cin>>t; int n,length;
while(t--)
{
cin>>n;
cin.get(); for(i = ; i < n; i++)
{
scanf("%s",strs[i]);
} for(i = ; i < n; i++) length = strlen(strs[]);
char substr[NUM + ],substr2[NUM + ];
int res = ;
for(i = ; i <= length; i++)
{
for(j = ; (j+i-) < length; j++)
{
strncpy(substr,&strs[][j],i);
substr[i] = '\0';
strcpy(substr2,substr); for(k = ; k < (i+)/; k++)
{
char tmp = substr2[k];
substr2[k] = substr2[i--k];
substr2[i--k] = tmp;
} //cout<<"substr="<<substr<<",substr2="<<substr2<<endl;
for(k = ; k < n; k++)
{
if(!strstr(strs[k],substr) && !strstr(strs[k],substr2)) break;
}
if(k >= n )
{
res = i;
break;
}
}
} cout<<res<<endl;
}
return ;
}