Pagini recente » Istoria paginii runda/lot2006z3/clasament | Cod sursa (job #2703941) | Cod sursa (job #1153649) | Istoria paginii runda/1.i | Cod sursa (job #1912564)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
#define cheie 666013
vector < int > L[cheie];
int cauta(int x)
{
int j = x % cheie;
for(int i = 0; i < L[j].size(); i++)
if(L[j][i] == x)
return 1;
return 0;
}
void adauga(int x)
{
if(!cauta(x))
L[x % cheie].push_back(x);
}
void sterge(int x)
{
if(cauta(x))
{
int j = x % cheie;
for(int i = 0; i < L[j].size(); i++)
if (L[j][i] == x)
{ L[j][i] = L[j][L[j].size() - 1];
L[j].pop_back();
break;
}
}
}
void citire()
{
int n, x, y;
fin >> n;
for(short i = 1; i <= n; i++)
{
fin >> x >> y;
if(x == 1)
adauga(y);
if (x == 2)
sterge(y);
if(x == 3)
fout << cauta(y) << "\n";
}
}
int main()
{
citire();
return 0;
}