#pragma warning(disable : 4786)
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
void run()
{
int i,n;
scanf("%d",&n);
getchar();
vector<string> v(n);
for(i=0;i<n;i++)
{
char t[30];
scanf("%s",&t);
v[i]=t;
}
sort(v.begin(),v.end());
int cnt=0;
for(i=0;i<n;i++)
{
string t=v[i];
int m=t.size();
for(int j=i+1;j<n;j++)
{
if (v[j].substr(0,m)==t)
{
cnt++;
}
else
{
break;
}
}
}
if (cnt>11519)
cout << cnt%11519 << endl;
else
cout << cnt << endl;
}
int main(){
int total;
scanf("%d",&total);
for(int now=1; now<=total; now++) run();
return 0;
}
Hdu 1894 String Compare 程序参考
最新推荐文章于 2018-02-03 18:40:00 发布