1 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int N=62929; int T,a[54188]; vector<int>haash[N]; int hs(int n){ return (n%N+N)%N; } bool not_found(int n){ if(haash[hs(n)].size()==0){ return true; } for(long unsigned int i=0;i<haash[hs(n)].size();i++){ if(haash[hs(n)][i]==n){ return false; } } return true; } int main(){ scanf("%d",&T); while(T--){ int n; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a[i]); if(not_found(a[i])){ printf("%d ",a[i]); haash[hs(a[i])].push_back(a[i]); } } printf("\n"); memset(a,0,sizeof(a)); for(int i=0;i<N;i++){ haash[i].clear(); } } return 0; }
- 1
Information
- ID
- 309
- Time
- 1500ms
- Memory
- 125MiB
- Difficulty
- 9
- Tags
- # Submissions
- 93
- Accepted
- 7
- Uploaded By