这题看起来就像是什么都能做,扔set扔map(或者unordered),自己写平衡树,甚至sort一遍都能a毕竟可以离线
但是当作hash的练手题,经由zyx的指导后a了,调了几次参数貌似像我这样写法%613最好?
//By Richard #include <cstdio> #include <vector> #include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include <cmath> #include <ctime> #define rep(x,y,z) for (int x=(y);(x)<=(z);(x)++) #define per(x,y,z) for (int x=(y);(x)>=(z);(x)--) #define log2(x) (31-__builtin_clz(x)) #define mod (int)(1e9+7) #define inf 0x3f3f3f3f #define cls(x) memset(x,0,sizeof(x)) #ifdef DEBUG #define debugdo(X) X #define debugndo(X) #define debugout(X) cout<<(#X)<<"="<<(X)<<endl #else #define debugdo(X) #define debugndo(X) X #define debugout(X) #endif // debug #ifdef ONLINE_JUDGE #define debugdo(X) #define debugndo(X) #define debugout(X) #endif #define putarray(x,n) rep(iiii,1,n) printf("%d ",x[iiii]) #define mp make_pair using namespace std; typedef pair<int,int> pairs; typedef long long LL; /////////////////////read3.0//////////////////////////////////// template <typename T> inline void read(T &x){char ch;x=0;bool flag=false;ch=getchar();while (ch>'9'||ch<'0') {ch=getchar();if (ch=='-') flag=true;}while ((ch<='9'&&ch>='0')){x=x*10+ch-'0';ch=getchar();}if (flag) x*=-1;} template <typename T> inline void read(T &x,T &y){read(x);read(y);} /////////////////variables&functions////////////////////vector <int> v[1030];
int n,T,x;
int main()
{
scanf("%d",&T);
while (T–)
{
cls(v);
scanf("%d",&n);
rep(i,1,n)
{
scanf("%d",&x);
int temp=abs(x)%1029;
if (!v[temp].empty())
{
bool flag=false;
for (vector<int>::iterator it=v[temp].begin();it!=v[temp].end();it++) if (*it==x) {flag=true;break;}
if (!flag)
{
v[temp].push_back(x);
printf(" %d",x);
}
}
else
{
v[temp].push_back(x);
if (i==1) printf("%d",x);
else printf(" %d",x);
}
}
putchar(‘\n’);
}
return 0;
}