Pagini recente » Cod sursa (job #2868350) | Cod sursa (job #1215304) | Cod sursa (job #2086213) | Cod sursa (job #1371394) | Cod sursa (job #1527615)
#include <iostream>
#include <vector>
#include <fstream>
#define int2 long long
#define hash 1000017
using namespace std;
vector<int2> table[hash+1];
int j;
bool found(int2 x)
{
int p = x % hash;
for(int i=0; i<table[p].size(); i++)
if (table[p][i] == x) { j=i; return 1;}
return 0;
}
void ins(int2 x)
{
int p = x % hash;
if (!found(x))
table[p].push_back(x);
return;
}
void del(int2 x)
{
int p = x % hash;
if (found(x))
table[p].erase(table[p].begin()+j);
return;
}
int main()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int2 val, act, n;
f >> n;
for(int i=1; i<=n; i++)
{
f >> act >> val;
if (act == 1) ins(val);
else
if (act == 2) del(val);
else g << found(val) << "\n";
}
f.close();
g.close();
return 0;
}