Pagini recente » Cod sursa (job #104928) | Monitorul de evaluare | Monitorul de evaluare | Cod sursa (job #3174540) | Cod sursa (job #1920897)
#include<fstream>
#include<set>
#define key 45000
using namespace std;
set<int> s[key + 5];
int m, op, x;
int _list;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
void hash_insert(int x)
{
_list = x % key;
if(s[_list].find(x) == s[_list].end())
{
s[_list].insert(x);
}
}
void hash_erase(int x)
{
_list = x % key;
s[_list].erase(x);
}
void hash_query(int x)
{
_list = x % key;
if(s[_list].find(x) != s[_list].end())
{
cout << "1\n";
}else
{
cout << "0\n";
}
}
int main()
{
cin >> m;
while(m--)
{
cin >> op >> x;
if(op == 1)
{
hash_insert(x);
continue;
}
if(op == 2)
{
hash_erase(x);
continue;
}
hash_query(x);
}
return 0;
}