#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct node {
long long int first,second;
} a[50001];
bool cmp(node c,node b) {
if(c.first==b.first)
return c.second<b.second;
return c.first<b.first;
}
bool cmp1(node c,node b) {
return c.second<b.second;
}
int main() {
long long int i,n,m,j;
scanf("%lld",&n);
for(i=1; i<=n; i++) {
scanf("%lld",&m);
for(j=0; j<=m-1; j++) {
long long int x;
scanf("%lld",&x);
a[j].first=x;
a[j].second=j;
}//读入
sort(a,a+m,cmp);//排序
int t=0;
for(j=0; j<=m-1; j++) {
if(a[j].first!=a[j-1].first) {
a[t].first=a[j].first;
a[t++].second=a[j].second;
}
}//手写unique
t--;
sort(a,a+t+1,cmp1);//按照序列再排回来
for(j=0; j<=t; j++)
printf("%lld ",a[j].first);//输出
printf("\n");
}
}
代码是像这样的,个人不知道哪里错了,求大佬们救救