Pagini recente » Cod sursa (job #3182248) | Cod sursa (job #742833) | Cod sursa (job #396909) | Cod sursa (job #2214478) | Cod sursa (job #1863138)
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <cstdio>
#include <climits>
#define PII pair < int , int >
#define MP make_pair
#define PB push_back
using namespace std;
vector <int> H[666013];
vector <int> :: iterator it;
int n,op,val;
int calculateKey (int val)
{
return val%666013;
}
void insertValue(int val)
{
int key = calculateKey(val);
H[key].PB(val);
}
void deleteValue(int val)
{
int key = calculateKey(val);
for(it = H[key].begin(); it!=H[key].end(); it++)
{
if (*it == val)
{H[key].erase(it); break;}
}
}
int checkValue(int val)
{
int key = calculateKey(val);
for(it = H[key].begin(); it!=H[key].end(); it++)
if (*it == val) return 1;
return 0;
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for (int i=1 ; i<=n ; ++i)
{
scanf("%d %d",&op,&val);
switch(op)
{
case 1: insertValue(val); break;
case 2: deleteValue(val); break;
case 3: printf("%d\n",checkValue(val)); break;
}
}
return 0;
}