Cod sursa(job #767224)

Utilizator geniuanduOncescu Andreea geniuandu Data 12 iulie 2012 23:12:54
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.94 kb
#include<cstdio>
#include<vector>
using namespace std;
vector <int> a[666014];
vector <int> ::iterator it;
int j,n,i,op,x,y;
char s[16];
int main()
{
	freopen("hashuri.in","r",stdin);
	freopen("hashuri.out","w",stdout);
	scanf("%d\n",&n);
	for(i = 1;i <= n;i ++)
	{
		//scanf("%d %d",&op,&x);
		gets(s);
		op=s[0]-48;
		x=0;
		for ( j = 2; s[j]<='9' && s[j]>='0'; j ++ )
			x=x*10 + s[j] - 48;
		y=x % 666013;
		if(op == 1)
		{
			for(it = a[y].begin();it != a[y].end(); it ++)
				if(*it == x )
					break;
			if(it == a[y].end())
				a[y].push_back(x);
		}
		else
			if(op == 2)
			{
				for(it = a[y].begin();it != a[y].end(); it ++)
					if(*it == x )
						break;
				if(it != a[y].end())
					a[y].erase(it);
			}
			else
			{
				for(it = a[y].begin();it != a[y].end(); it ++)
					if(*it == x )
						break;
				if(it != a[y].end())
					printf("1\n");
				else
					printf("0\n");
			}
	}
	return 0;
}