Pagini recente » Cod sursa (job #2594757) | Cod sursa (job #1391781) | Cod sursa (job #801949) | Cod sursa (job #870307) | Cod sursa (job #425015)
Cod sursa(job #425015)
#include <list>
#include <fstream>
#include <map>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
map<int, list<int> > H;
list<int>::iterator it;
int n,i,j,op,val;
int hash_func(int val)
{
return val%n;
}
int main()
{
in>>n;
for(i=1; i<=n; i++)
{
in>>op>>val;
if(op == 1)
H[hash_func(val)].push_back(val);
else if(op == 2)
{
it = H[hash_func(val)].begin();
while(*it != val && it != H[hash_func(val)].end())
it++;
if(it != H[hash_func(val)].end())
H[hash_func(val)].erase(it);
}
else if(op == 3)
{
it = H[hash_func(val)].begin();
while(*it != val && it != H[hash_func(val)].end())
it++;
out <<(it != H[hash_func(val)].end())<<'\n';
}
}
return 0;
}