Pagini recente » Cod sursa (job #1131606) | Cod sursa (job #1969079) | Cod sursa (job #1442168) | Cod sursa (job #1096244) | Cod sursa (job #1549334)
#include <iostream>
#include <fstream>
#include <vector>
#define p 6660131
using namespace std;
vector<int> v[p];
int found(int x)
{
int h = x % p;
for(int i=0; i<v[h].size(); i++)
{
if (v[h][i] == x) return i;
}
return -1;
}
void add(int x)
{
if (found(x) != -1) return;
int h = x % p;
v[h].push_back(x);
return;
}
void erase(int x)
{
int poz = found(x);
if (poz == -1) return;
int h = x % p;
swap(v[h][poz], v[h].back());
v[h].pop_back();
return;
}
int main()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n, act, x;
f >> n;
for(int i=1; i<=n; i++)
{
f >> act >> x;
if (act == 1) add(x);
else
if (act == 2) erase(x);
else
if (found(x) == -1) g << "0\n";
else g << "1\n";
}
f.close();
g.close();
return 0;
}