//又是暴力阿……想用字尾樹或者字尾樹組寫,但是不會阿……趕緊學習…… #include #include #include //#include using namespace std; char s[105][105],minstr[105]; int n; void strev(char *str){//此函數要自己寫 int i,j,len; char ch; len=strlen(str); for(i=0,j=len-1;i 0){ for(i=0;i<=len-len1;i++){ mark=1; strncpy(str1,minstr+i,len1); str1[len1]='/0'; strcpy(str2,str1); strev(str2); for(j=1;j<=n;j++){ if(strstr(s[j],str1)==NULL&&strstr(s[j],str2)==NULL){ mark=0; break; } } if(mark){ printf("%d/n",strlen(str1)); return 1; } } len1--; } return 0; } int main(){ int t,i,min,len; scanf("%d",&t); while(t--){ scanf("%d",&n); min=105; for(i=1;i<=n;i++){ scanf("%s",s[i]); len=strlen(s[i]); if(len