其实可以不加快读卡过去,但得优化下,像这样:
```cpp
#include<bits/stdc++.h>
using namespace std;
map<int, bool> mp;
int a;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t, n;
cin >> t;
for(int i = 1; i <= t; i ++)
{
mp.clear();
cin >> n;
for(int j = 1; j <= n; j ++)
{
cin >> a;
if (!mp.count(a))
{
cout << a << " ";
mp[a] = true;
}
}
cout << '\n';
}
return 0;
}
```
by chaynflow @ 2023-01-12 11:12:15
@[FZwangmuem](/user/677581)
by chaynflow @ 2023-01-12 11:13:24
tie?@[chy2011](/user/559665)
by _Glassy_Sky_ @ 2023-01-12 11:37:53
这两行作用自己bdfs
by chaynflow @ 2023-01-12 11:57:20
@[FZwangmuem](/user/677581) 不用`unordered_map`,用`unordered_set`+`vector`就能过(似乎`unordered_map`常数更大)
```cpp
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
unordered_set<int>us;
void solve(){
int n, x;
scanf("%d",&n);
for(int i=0;i<n;++i){
scanf("%d",&x);
v.push_back(x);
us.insert(x);
}
for(int i=0;i<n;++i){
if(us.count(v[i])){
cout<<*us.find(v[i])<<" ";
us.erase(v[i]);
}
}
cout<<endl;
v.clear();
us.clear();
}
int main(){
int t;
scanf("%d",&t);
while(t--){
solve();
}
}
```
by Enterprise_E @ 2023-02-06 22:23:41