我的想法就是暴力查找(wtcl)#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
while (n--)
{
int m;
cin >> m;
string* a = new string[m];
for (int i = 0; i < m; i++)
{
cin >> a[i];
}
cout << a[0];
for (int i = 1; i < m; i++)
{
bool flag = false;
for (int j = 0; j < i; j++)
{
if (a[j].substr(0, 3) == a[i].substr(0, 3))
{
break;
}
if (j == i - 1)
{
flag = true;
}
}
if (flag)
{
cout << " " << a[i];
}
}
cout << endl;
}
return 0;
}