行尾有空格会PE
真是日了狗了
#include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; int n,T; struct Data{ int id,x; friend bool operator<(Data A,Data B){return A.id<B.id;} }a[50005]; bool cmp(Data A,Data B){return A.x<B.x || (A.x==B.x && A.id<B.id);} int main(){ freopen("2761.in","r",stdin); freopen("2761.out","w",stdout); scanf("%d",&T); while(T--){ scanf("%d",&n); a[n+1].id=99999; for(int i=1;i<=n;i++)scanf("%d",&a[i].x),a[i].id=i; sort(a+1,a+n+1,cmp); for(int i=2;i<=n;i++)if(a[i].x==a[i-1].x)a[i].id=99999; sort(a+1,a+n+1); for(int i=1;i<=n;i++){if(a[i+1].id==99999){printf("%d\n",a[i].x);break;}else printf("%d ",a[i].x);} } return 0; }