re后四
查看原帖
re后四
529661
Chin_V楼主2022/7/24 19:24
#include<bits/stdc++.h>
using namespace std;
struct hash 
{
	bool hid[100000]={false};
	void ins(int x)//加入 
	{
		hid[x%999983]=true;
	}
	bool ask(int x)//查询 
	{
	    if(hid[x%999983]) return true;
	    return false;
	}
	void del(int x)//删除 
	{
		hid[x%999983]=false;		
	}
}a;
int main()
{
	int n,time;
	int b[100010];
	cin>>n; 
	while(n--)
	{
		cin>>time;
		for(int i=0;i<time;i++)
		{
			scanf("%d",&b[i]);
			a.ins(b[i]);
		}
		for(int i=0;i<time;i++)
		{
			if(a.ask(b[i]))
			{
				printf("%d ",b[i]);
				a.del(b[i]);
			}
		}
		cout<<endl;
	}
    return 0;
}
2022/7/24 19:24
加载中...