BZOJ2761 [JLOI2011]不重复数字

题面在这里

水水更健康

示例程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
inline char nc(){
static char buf[100000],*l=buf,*r=buf;
return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
inline int red(){
int res=0,f=1;char ch=nc();
while (ch<'0'||'9'<ch) {if (ch=='-') f=-f;ch=nc();}
while ('0'<=ch&&ch<='9') res=res*10+ch-48,ch=nc();
return res*f;
}

const int maxn=50005;
int tst,n;
set<int> S;
int main(){
tst=red();
while (tst--){
n=red();S.clear();
for (int i=1;i<=n;i++){
int x=red();
if (S.count(x)==0) printf("%d ",x),S.insert(x);
}putchar('\n');
}
return 0;
}