Description
You is given a number of case-sensitive strings of alphabetic characters, find the largest string x, such that either X, Or its inverse can is found as a substring of any of the given strings.
Input
The first line of the input file contains a single integer t (1 <= t <=), the number of test cases, followed by t He input data for each test case. The first line of all test case contains a single integer n (1 <= n <=), the number of given strings, followed by n lines, each representing one string of minimum length 1 and maximum length 100. There is no extra white space before and after a string.
Output
There should is one line per test case containing the length of the largest string found.
Sample Input
2 3abcdbcdffbrcd2roseorchid
Sample Output
22
#include<stdio.h>#include<string.h>#include<stdlib.h>#define MAXN105Char Lina[MAXN];Char A[MAXN][maxn];int x;voidLinstr(){int I;int Len=10000, Lens; Lina[0]=‘/‘;scanf("%d",&x);For(I=0; I<x; I++){scanf('%s '+ F[I]);int lens=Strlen(A[I]);If(len>lens){strcpy(Lina+ F[I]); Len= Lens;}}}IntFin(Char Str[],Char RTS[]){int I;For(I=0; I<x; I++){If(Strstr(A[I], str)==0&&Strstr(A[I], RTS)==0)Return0;}Return1;}IntFuck(){int ILenJ; Len=Strlen(Lina);For(I= Len; I>0; I--){For(j=0; J+i<=len; J++){Char Str[MAXN]={0}Rts[MAXN];strncpy(str, Lina+j, I);strcpy(RTSStr);Strrev(RTS);If(Fin(strRts)==1)return I;}}Return0;}IntMain(){int nNumscanf ( "%d" &n); while (N--) { linstr () num = fuck (); printf ( "%d \n "); return 0;< Span class= "Sh-cbracket" >
Substrings substring-----Search