Pagini recente » Cod sursa (job #682769) | Cod sursa (job #2961356) | Istoria paginii runda/5problemepanamaine | Cod sursa (job #2079868) | Cod sursa (job #2594791)
#include <bits/stdc++.h>
#define mod 106453
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
class Hashi
{
public:
int a;
list<int> Hash[mod];
bool exists(int x);
void insertt(int x);
void deletee(int x);
};
bool Hashi::exists(int x)
{
a = x % mod;
for(auto i = Hash[a].begin(); i != Hash[a].end(); ++ i)
if(*i == x)
return 1;
return 0;
}
void Hashi::insertt(int x)
{
if(exists(x))
return ;
a = x % mod;
Hash[a].push_back(x);
}
void Hashi::deletee(int x)
{
a = x % mod;
for(auto i = Hash[a].begin(); i != Hash[a].end(); ++ i)
if(*i == x)
{
Hash[a].erase(i);
break;
}
}
int main()
{
/* ios_base::sync_with_stdio(0);
cin.tie(0);*/
Hashi obj;
int n,op,x;
f >> n;
for(int i = 1; i <= n; ++ i)
{
f >> op >> x;
switch (op)
{
case 1: obj.insertt(x); break;
case 2: obj.deletee(x); break;
default: g << obj.exists(x) << '\n'; break;
}
}
}