RE后四个点,桶思想求助
查看原帖
RE后四个点,桶思想求助
1268524
DX3906_ourstar楼主2024/7/30 11:52

link

#include<iostream>
#include<algorithm>
#define re register
using namespace std;

const int N = 1e7 + 5;

int T;

int a[N];
bool bucket[N];

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>T;
	while(T --){
		int n;
		cin>>n;
		for(re int i = 1;i <= n;i ++){
			cin>>a[i];
			bucket[a[i]] = true;
		}
		for(re int i = 1;i <= n;i ++){
			if(bucket[a[i]]){
				cout<<a[i]<<" ";
				bucket[a[i]] = false;
			}
		}
		cout<<"\n";
	}
	return 0;
}
2024/7/30 11:52
加载中...