Pagini recente » Cod sursa (job #2516562) | Cod sursa (job #2620536) | Cod sursa (job #837270) | Cod sursa (job #3133947) | Cod sursa (job #2429177)
#include <bits/stdc++.h>
#define MOD 666013
using namespace std;
ifstream fin("hashuri.in") ;
ofstream fout("hashuri.out") ;
int n, op, x;
vector <int> H[MOD] ;
int HASH(int x)
{
return x%MOD;
}
void inserare(int x)
{
H[HASH(x)].push_back(x);
}
void sterge(int x)
{
int h = HASH(x) ;
vector <int> V ;
for(int i = 0; i<H[h].size(); i++)
if(H[h][i] == x)
{
swap(H[h][i] , H[h][H[h].size()-1]) ;
H[h].pop_back() ;
break ;
}
}
int cauta(int x)
{
int h = HASH(x) ;
for(auto it : H[h])
if(it == x)
return 1;
return 0 ;
}
int main()
{
fin >> n ;
for(int i=1; i<=n; i++)
{
fin >> op >> x ;
if(op == 1 && !cauta(x))
inserare(x) ;
else if(op == 2)
sterge(x) ;
else
fout << cauta(x) << "\n" ;
}
return 0;
}