Pagini recente » Cod sursa (job #3236226) | Cod sursa (job #5153) | Cod sursa (job #2586917) | Cod sursa (job #1619984) | Cod sursa (job #2512244)
#include <iostream>
#include <vector>
#include <fstream>
#include <set>
#define NMAX 1000000
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector<int> h[NMAX];
int add_to_set(int e)
{
int hashvalue = e%NMAX;
for(auto x:h[hashvalue])
if(x==e)
return -1;
h[hashvalue].push_back(e);
return 1;
}
void sterge(int e)
{
int hashvalue = e%NMAX;
for(unsigned int i=0; i<h[hashvalue].size(); i++)
if(h[hashvalue][i]==e)
{
h[hashvalue].erase(h[hashvalue].begin()+i);
}
}
void o_3(int e)
{
int hashvalue = e%NMAX;
for(auto x:h[hashvalue])
if(x==e)
{
fout<<1<<'\n';
return;
}
fout<<0<<'\n';
}
int main()
{
int n, o, x;
fin>>n;
while(n--)
{
fin>>o>>x;
if(o==1)
add_to_set(x);
else if(o==2)
sterge(x);
else
o_3(x);
}
return 0;
}