Pagini recente » Rating UniTBV MorcovMadalin AndreiGeorge SergiuNeamtu (UniTBV) | Cod sursa (job #1164428) | Cod sursa (job #2562866) | Cod sursa (job #2664564) | Cod sursa (job #1920914)
#include<fstream>
#include<set>
#define key 2000000
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;
}