#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string str[50010];
bool cmp(string x,string y)
{
int len_x,len_y,i,count=0;
len_x=x.length();
len_y=y.length();
if(len_x>len_y)
return false;
if(len_x<=len_y)
{
for(i=0;i<len_x;i++)
{
if(x.at(i)==y.at(i))
count++;
}
if(count==len_x)
return true;
else
return false;
}
}
int main()
{
long int n,m,i,j,k,count;
char s[35];
cin>>n;
for(i=0;i<n;i++)
{
count=0;
cin>>m;
getchar();
for(j=0;j<m;j++)
{
scanf("%s",s);
str[j]=s;
}
sort(str,str+m);
for(j=0;j<m-1;j++)
{
for(k=j+1;k<m;k++)
{
if(cmp(str[j],str[k]))
count++;
else
break;
}
}
if(count>11519)
count=count%11519;
cout<<count<<endl;
}
}
hdu 1894 字典序问题,先排序,在剪枝
最新推荐文章于 2017-07-30 22:20:15 发布