Pagini recente » Cod sursa (job #1091826) | Cod sursa (job #1361647) | Cod sursa (job #2671186) | Cod sursa (job #2494333) | Cod sursa (job #2896400)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int nrprim = 100019;
vector <int> h[100019];
bool gaseste(int x)
{
int nr = x % nrprim;
for(int i = 0; i < h[nr].size(); i++)
if(h[nr][i] == x) return 1;
else return 0;
}
void sterge (int x)
{
int nr = x % nrprim;
if(gaseste(x))
for(int i = 0; i < h[nr].size(); i++)
if(h[nr][i] == x)
{
h[nr][i] = -1;
break;
}
}
int main()
{
int n, i, x, k;
f>>n;
for(i=0;i<n;i++)
{
f>>k>>x;
if(k==1)
{
if(!gaseste(x)) h[x % nrprim].push_back(x);
}
else if(k==2)
{
sterge(x);
}
else g<<gaseste(x)<<endl;
}
}