Pagini recente » Rating Marcel Ionescu (MarcelIonescu) | Cod sursa (job #1292575) | Cod sursa (job #294883) | Cod sursa (job #1336652) | Cod sursa (job #2622845)
#include <iostream>
#include <fstream>
#include <vector>
#define mod 59999
using namespace std;
vector<int> hashtable[mod];
int cautare(int x){
int index=x%mod;
for(int i=0; i< hashtable[index].size(); i++)
if(hashtable[index][i] == x)
return 1;
return 0;
}
void adaugare(int x){
hashtable[x%mod].push_back(x);
}
void stergere(int x){
int m = x % mod;
for (int i = 0; i < hashtable[m].size(); i++)
if(hashtable[m][i] == x)
hashtable[m].erase(hashtable[m].begin()+i);
}
int main()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,x,op;
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;
}