Pagini recente » Cod sursa (job #876071) | Cod sursa (job #825413) | Cod sursa (job #1706559) | Cod sursa (job #2352998) | Cod sursa (job #1915829)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
#define cheie 66013
vector <int> V[cheie];
int n;
short op;
void Citire()
{
fin >> n;
}
int cauta(int x)
{
for(int i = 0; i < V[x%cheie].size(); i++)
if(V[x%cheie][i] == x)
return 1;
return 0;
}
void adauga(int x)
{
if(!cauta(x))
V[x%cheie].push_back(x);
}
void sterge(int x)
{
if(cauta(x))
for(int i = 0; i < V[x%cheie].size(); i++)
if(x == V[x%cheie][i])
{
V[x%cheie][i] = V[x%cheie][V[x%cheie].size() - 1];
V[x%cheie].pop_back();
break;
}
}
int main()
{
Citire();
int x;
for(int j = 1; j <= n; j++)
{
fin >> op >> x;
if(op == 1)
adauga(x);
else if(op == 2)
sterge(x);
else if(op == 3)
fout << cauta(x) << "\n";
}
fin.close();
fout.close();
return 0;
}