Pagini recente » Cod sursa (job #2466993) | Cod sursa (job #1227219) | Cod sursa (job #1466340) | Cod sursa (job #2438705) | Cod sursa (job #2622838)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
vector<int> hashtable[666013];
int n,x,op;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
bool cautare(int x){
int index=x%666013;
for(int i=0; i< hashtable[index].size(); i++)
if(hashtable[index][i] == x)
return 1;
return 0;
}
void adaugare(int x){
if(cautare(x))
return;
hashtable[x%666013].push_back(x);
}
void stergere(int x){
int m = x % 666013;
for (int i = 0; i < hashtable[m].size(); i++)
if(hashtable[m][i] == x)
hashtable[m].erase(hashtable[m].begin()+i);
}
int main()
{
f>>n;
while(n--){
f>>op>>x;
if(op==1)
adaugare(x);
else if(op==2)
stergere(x);
else g<<cautare(x)<<endl;
}
return 0;
}