Pagini recente » Cod sursa (job #56924) | Cod sursa (job #1296661) | Cod sursa (job #1883578) | Cod sursa (job #207697) | Cod sursa (job #1314508)
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <utility>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <sstream>
#include <deque>
#include <bitset>
#include <complex>
#include <functional>
#include <memory>
#include <numeric>
using namespace std;
#define x first
#define y second
enum {
MAX = 2000001,
};
int table[MAX], PMAX = 1999993;
int hashv(int x) {
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = ((x >> 16) ^ x);
return x % PMAX;
}
void add(int val) {
int h = hashv(val);
while(table[h]) h++;
table[h] = val;
}
bool is(int val) {
int h = hashv(val);
while(table[h] && table[h] != val) h++;
if(!table[h])
return false;
return true;
}
void del(int val) {
int h = hashv(val);
while(table[h] && table[h] != val) h++;
if(table[h]) table[h] = -1;
}
int main () {
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n;
fin >> n;
int t, val;
for(int i = 0; i < n; i++) {
fin >> t >> val;
if(t == 1) {
add(val);
}
else if (t == 3) {
if(is(val)) fout << "1\n";
else fout << "0\n";
}
else {
del(val);
}
}
return 0;
}