Pagini recente » Cod sursa (job #3296294) | Cod sursa (job #404583) | Cod sursa (job #2265610) | Cod sursa (job #2232901) | Cod sursa (job #2833705)
#include <bits/stdc++.h>
#define MOD 123457
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
unordered_map <int, bool>v;
vector <int> H[MOD];
int x, c, n;
void insert(int x)
{
int aux;
aux=x%MOD;
for(auto it: H[aux])
if(it==x)
return;
H[aux].push_back(x);
}
void stergere(int x)
{
int aux, s;
aux=x%MOD;
s=H[aux].size();
for(int i=0; i<s; i++)
{
if(H[aux][i]==x)
{
H[aux][i]=H[aux][s-1];
H[aux].pop_back();
}
}
}
bool verif(int x)
{
int aux;
aux=x%MOD;
for(auto it: H[aux])
if(it==x)
return true;
return false;
}
int main()
{
fin >> n;
for(int i=1; i<=n; i++)
{
fin >> c >> x;
if(c==1)
insert(x);
if(c==2)
stergere(x);
if(c==3)
fout << verif(x) << "\n";
}
return 0;
}