Pagini recente » Cod sursa (job #3269571) | Cod sursa (job #1660715) | Cod sursa (job #298690) | Cod sursa (job #498623) | Cod sursa (job #2450953)
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <math.h>
#include <queue>
#include <string>
#include <map>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
#define MOD 666013
vector<int>vp[666013];
namespace hashing
{
void insert_value(int x)
{
int index = x % MOD;
if (find(vp[index].begin(), vp[index].end(), x) == vp[index].end())
vp[index].push_back(x);
}
void erase_value(int x)
{
int index = x % MOD;
vector<int>::iterator it = find(vp[index].begin(), vp[index].end(), x);
if (it != vp[index].end())
vp[index].erase(it);
}
}
int main()
{
ios_base::sync_with_stdio(false);
int n;
fin >> n;
for (int i = 0; i < n; i++)
{
int a, b;
fin >> a >> b;
if (a == 1)
hashing::insert_value(b);
if (a == 2)
hashing::erase_value(b);
if (a == 3)
{
int index = b % MOD;
if (find(vp[index].begin(), vp[index].end(), b) != vp[index].end())
fout << "1\n";
else
fout << "0\n";
}
}
}