Pagini recente » Cod sursa (job #290824) | Cod sursa (job #243454) | Cod sursa (job #1642442) | Cod sursa (job #1525692) | Cod sursa (job #1210415)
#include <fstream>
#include <set>
//#define M 666013
#define M 300007
#define H(x) (x % M)
using namespace std;
set<int>* S[M];
ifstream ifs("hashuri.in");
ofstream ofs("hashuri.out");
int main()
{
int n;
ifs >> n;
for (int i = 1; i <= n; ++i)
{
int op, x;
ifs >> op >> x;
// Determine the bucket
int hx = H(x);
if (S[hx] == NULL)
{
S[hx] = new set<int>;
}
set<int>* bucket = S[hx];
set<int>::iterator it = bucket->find(x);
switch(op)
{
case 1:
bucket->insert(x);
break;
case 2:
bucket->erase(x);
break;
case 3:
ofs << (it == bucket->end() ? 0 : 1) << "\n";
break;
}
}
return 0;
}