Pagini recente » Cod sursa (job #245227) | Cod sursa (job #2086897) | Cod sursa (job #212661) | Cod sursa (job #2280081) | Cod sursa (job #2736457)
#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 = 20233;
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;
}