Cod sursa(job #2040926)

Utilizator zhm248Mustatea Radu zhm248 Data 16 octombrie 2017 17:56:14
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.16 kb
/*#include<cstdio>
#include<set>
using namespace std;
set<int>s;
int main()
{
	freopen("hashuri.in","r",stdin);
	freopen("hashuri.out","w",stdout);
	int n,i,c,x;
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d%d",&c,&x);
		if(c==1)
		s.insert(x);
		else
		{
			if(c==2)
			{
				if(s.find(x)!=s.end())
				s.erase(s.find(x));
			}
			else
			{
				if(s.find(x)!=s.end())
				printf("1\n");
				else
				printf("0\n");
			}
		}
	}
	return 0;
}*/
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int p=666013;
vector<int>g[p+1];
int main()
{
	freopen("hashuri.in","r",stdin);
	freopen("hashuri.out","w",stdout);
	int n,i,c,x;
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d%d",&c,&x);
		if(c==1)
		{
			if(find(g[x%p].begin(),g[x%p].end(),x)==g[x%p].end())
			g[x%p].push_back(x);
		}
		else
		{
			if(c==2)
			{
				if(find(g[x%p].begin(),g[x%p].end(),x)!=g[x%p].end())
			    g[x%p].erase(find(g[x%p].begin(),g[x%p].end(),x));
			}
			else
			{
				if(find(g[x%p].begin(),g[x%p].end(),x)!=g[x%p].end())
				printf("1\n");
				else
				printf("0\n");
			}
		}
	}
	return 0;
}