Pagini recente » Cod sursa (job #149531) | clasament-teme | Rating Bojoaga Petru Matei (Matei007) | Cod sursa (job #359643) | Cod sursa (job #1461491)
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ofstream fout("hashuri.out");
ifstream fin("hashuri.in");
const int MOD = 666013; // a.k.a the satanico-illuminati number
int n, op, x;
vector<int> Hash[MOD];
int get()
{
int poz = x % MOD;
auto it = find(Hash[poz].begin(), Hash[poz].end(), x);
if(it != Hash[poz].end()) return 1;
return 0;
}
void add()
{
int poz = x % MOD;
auto it = find(Hash[poz].begin(), Hash[poz].end(), x);
if(it == Hash[poz].end()) Hash[poz].push_back(x);
}
void del()
{
int poz = x % MOD;
auto it = find(Hash[poz].begin(), Hash[poz].end(), x);
if(it != Hash[poz].end()) Hash[poz].erase(it);
}
int main()
{
fin >> n;
for(int i=1; i<=n; i++)
{
fin >> op >> x;
switch(op)
{
case 1: { add(); break; }
case 2: { del(); break; }
case 3: { fout << get() << '\n'; break; }
}
}
return 0;
}