set+快读
不吸氧过
by Xeqwq @ 2021-12-26 19:09:43
`__gnu_pbds::gp_hash_table` 能过.
在这道题里比 `std::unordered_map` 快很多.
by 望月Asta @ 2021-12-26 19:35:29
@[CheckMid](/user/263589)
```unordered_map```
加
```vector```
可过。
by Leonid @ 2021-12-26 20:01:21
@[FriskLSZ](/user/420692) 没必要加 vector 吧?
```cpp
#include<iostream>
#include<unordered_map>
using namespace std;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
unordered_map<int, bool> mp;
for (int i = 1; i <= n; i++) {
int a;
cin >> a;
if (!mp.count(a)) {
cout << a << ' ';
mp[a] = true;
}
}
cout << endl;
}
return 0;
}
```
输入的时候直接判断即可吧。
by int64 @ 2021-12-26 21:30:24
@[int64](/user/360331) 我喜欢用()
by Leonid @ 2021-12-28 20:41:18
我就是用map过的,嘿嘿
```
#include<iostream>
#include<map>
using namespace std;
map<int,int> q;
int a[50005],book[50005];
int main()
{
int m,n;
cin>>m;
for(int i=1;i<=m;i++)
{
q.clear();
cin>>n;
for(int j=1;j<=n;j++)
{
cin>>a[j];
if(q[a[j]]==0)
{
q[a[j]]=1;
book[j]=1;
}
else book[j]=2;
}
for(int j=1;j<=n;j++)
if(book[j]==1) cout<<a[j]<<" ";
cout<<endl;
}
return 0;
}
```
by 浮幻精灵 @ 2022-02-17 19:23:33