Pagini recente » Cod sursa (job #2760180) | Cod sursa (job #1715777) | Cod sursa (job #1176490) | Cod sursa (job #1179254) | Cod sursa (job #1469544)
#include <iostream>
#include <stdio.h>
#include <vector>
#define Key 60005
using namespace std;
vector<int> M[Key];
int N;
bool Find(int x)
{
int list=x%Key;
for(vector<int>::iterator it=M[list].begin();it!=M[list].end();it++)
if(x==*it)
return true;
return false;
}
void Add(int x)
{
if(Find(x)==false)
M[x%Key].push_back(x);
}
void Delete(int x)
{
int list=x%Key;
for(vector<int>::iterator it=M[list].begin();it!=M[list].end();it++)
if(x==*it)
{
M[list].erase(it);
return;
}
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&N);
for(int i=1;i<=N;i++)
{
int op,x;
scanf("%d%d",&op,&x);
if(op==1)
Add(x);
if(op==2)
Delete(x);
if(op==3)
printf("%d\n",Find(x));
}
}