4
23
2016
0

[BZOJ2761] [JLOI2011]不重复数字

行尾有空格会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;
}
Category: BZOJ | Tags: OI bzoj | Read Count: 675

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com