Pagini recente » Cod sursa (job #272217) | Cod sursa (job #2645075) | Cod sursa (job #1788674) | Cod sursa (job #2889015) | Cod sursa (job #2736455)
#include <bits/stdc++.h>
#include <list>
#include <fstream>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
void printList(list<int> g)
{
list <int> :: iterator it;
for(it = g.begin(); it != g.end(); ++it)
cout << '\t' << *it;
cout << '\n';
}
struct hashTable{
list<int> l;
};
int main() {
int buckets = 10009;
hashTable hash[buckets];
int n;
f>>n;
for(int i=0;i<n;i++)
{
int op,val;
f>>op>>val;
if(op == 1)
{
hash[val%buckets].l.push_back(val);
}
else if(op == 2)
{
hash[val%buckets].l.remove(val);
}
else if(op == 3)
{
int ok=0;
list <int> :: iterator it;
for(it = hash[val%buckets].l.begin(); it != hash[val%buckets].l.end(); ++it)
if(*it == val)
{
g<<1<<'\n';
ok = 1;
break;
}
if(ok==0)
g<<0<<'\n';
}
}
return 0;
}