Pagini recente » Cod sursa (job #2208623) | Cod sursa (job #300727) | Cod sursa (job #2342432) | Cod sursa (job #1959283) | Cod sursa (job #1545723)
#include <iostream>
#include <fstream>
#include <string.h>
#include <vector>
//#include <queue>
//#include <algorithm>
using namespace std;
const int nmax = 600000;
vector <int> H[nmax];
void ins(int x);
void del(int x);
int query(int x);
int main(){
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int m,a,x;
scanf("%d", &m);
for (;m--;) {
scanf("%d %d", &a, &x);
switch (a)
{
case 1 :
ins(x);
break;
case 2 :
del(x);
break;
case 3:
printf("%d \n",query(x));
break;
}
}
fclose(stdin);
fclose(stdout);
return 0;
}
void ins(int x) {
int i = x % nmax;
bool q = false;
for (int j = 0; j < H[i].size() && !q; j++)
q = x == H[i][j];
if (!q) H[i].push_back(x);
}
void del(int x){
int i = x % nmax,j;
bool q = false;
for (j = 0; j < H[i].size() && !q; j++)
q = x == H[i][j];
if (q) {
H[i].erase(H[i].begin()+j-1);
}
}
int query(int x) {
int i = x % nmax;
bool q = false;
for (int j = 0; j < H[i].size() && !q; j++)
q = x == H[i][j];
return (q ? 1 : 0);
}