BZOJ2761_不重复数字_KEY
Map水过(或set也行)。
code:
/************************************************************** Problem: 2761 User: yekehe Language: C++ Result: Accepted Time:1060 ms Memory:10988 kb ****************************************************************/ #include <cstdio> #include <map> using namespace std; char tc() { static char fl[10000000],*A=fl,*B=fl; return A==B&&(B=(A=fl)+fread(fl,1,10000000,stdin),A==B)?EOF:*A++; } int read() { char c;while(c=getchar(),(c<'0'||c>'9')&&c!='-');int x=0,y=1;c=='-'?y=-1:x=c-'0'; while(c=getchar(),c>='0'&&c<='9')x=x*10+c-'0';return x*y; } int T,N,d; map<int,bool>S; int main() { // freopen("x.txt","w",stdout); T=read(); while(T--){ N=read();S.clear();d=0; for(int i=1;i<=N;i++){ int x=read(); if(!S[x]){S[x]=true;if(!d){d=1;printf("%d",x);}else printf(" %d",x);} } puts(""); } return 0; }