Pagini recente » Cod sursa (job #333899) | Clasament vendetta_marian_tarina | Cod sursa (job #1630056) | Monitorul de evaluare | Cod sursa (job #2743514)
#include <iostream>
#include<vector>
#include<fstream>
using namespace std;
#define HASH 999983
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int N;
vector<int> LISTE[HASH]; // array of 999983 vectors
inline vector<int>::iterator Find(int x)
{
int hashPos = x % HASH;
vector<int>::iterator it;
for(it = LISTE[hashPos].begin(); it!= LISTE[hashPos].end(); it++)
if(*it == x)
return it;
return LISTE[hashPos].end();
}
inline void Insert(int x)
{
int hashPos = x % HASH;
if(Find(x) == LISTE[HASH].end())
LISTE[hashPos].push_back(x);
}
inline void Erase(int x)
{
int hashPos = x % HASH;
vector<int>::iterator it;
it = Find(x);
if(it!= LISTE[hashPos].end())
LISTE[hashPos].erase(it);
}
int main()
{
int n, op, x;
fin>>n;
for(int i = 0; i< n; i++)
{
fin>>op>>x;
if(op == 1) {Insert(x); continue;}
if(op == 2) {Erase(x);continue;}
fout<<((Find(x) != LISTE[x%HASH].end())&1);
}
return 0;
}