Pagini recente » Cod sursa (job #418828) | Cod sursa (job #2106776) | Cod sursa (job #1351744) | Cod sursa (job #2177403) | Cod sursa (job #2222530)
#include <fstream>
#include <vector>
#define prim 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,op,x;
vector <long> Hash[prim];
bool cauta(long x)
{
int rest=x%prim;
for(int i = 0; i<Hash[rest].size(); ++i)
{
if(Hash[rest][i] == x)
return 1;
}
return 0;
}
void push(long x)
{
if(cauta(x)==0)
{
Hash[x%prim].push_back(x);
}
}
void sterge(long x)
{
int rest = x%prim;
for(int i = 0; i<Hash[rest].size(); ++i)
{
if(Hash[rest][i]==x)
{
Hash[rest].erase(Hash[rest].begin() + i);
return;
}
}
}
int main()
{
f>>n;
while(n--)
{
int op;
long x;
f>>op;
f>>x;
if(op==1)
{
push(x);
}
else
if(op==2)
{
sterge(x);
}
else
{
g<<cauta(x)<<'\n';
}
}
return 0;
}