Pagini recente » Cod sursa (job #2368345) | Cod sursa (job #1112282) | Cod sursa (job #546658) | Cod sursa (job #1785188) | Cod sursa (job #1895137)
#include<fstream>
#include<set>
#define key 100000
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
set<int> s[key + 5];
int lista, x, op, n;
void insert_hash(int x)
{
lista = x % key;
if(s[lista].find(x) == s[lista].end())
{
s[lista].insert(x);
}
}
void erase_hash(int x)
{
lista = x % key;
if(s[lista].find(x) != s[lista].end())
s[lista].erase(x);
}
void query_hash(int x)
{
lista = x % key;
if(s[lista].find(x) != s[lista].end())
{
cout << "1\n";
}else
{
cout << "0\n";
}
}
int main()
{
cin >> n;
for(;n--;)
{
cin >> op >> x;
if(op == 1)
{
insert_hash(x);
continue;
}
if(op == 2)
{
erase_hash(x);
continue;
}
query_hash(x);
}
return 0;
}