Pagini recente » Cod sursa (job #2458753) | Cod sursa (job #1571069) | Istoria paginii runda/pre002 | Cod sursa (job #1785809) | Cod sursa (job #2622843)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
vector<int> hashtable[59999];
int n,x,op;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
bool cautare(int x){
int index=x%59999;
for(int i=0; i< hashtable[index].size(); i++)
if(hashtable[index][i] == x)
return 1;
return 0;
}
void adaugare(int x){
hashtable[x%59999].push_back(x);
}
void stergere(int x){
int m = x % 59999;
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;
}