Pagini recente » Cod sursa (job #2631778) | Cod sursa (job #273621) | Cod sursa (job #346831) | Cod sursa (job #818792) | Cod sursa (job #3131941)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
#define constanta 666013
vector<int> h[666013];
void insert(int val)
{
int hf = val % constanta;
for (auto i : h[hf])
if (i == val)
{
return;
}
h[hf].push_back(val);
}
int find(int val)
{
int hf = val % constanta;
for (auto i : h[hf])
if (i == val)
return 1;
return 0;
}
void remove(int val)
{
int hf = val % constanta;
for (int i = 0; i < h[hf].size(); i++)
if (h[hf][i] == val)
h[hf].erase(h[hf].begin() + i);
}
int main()
{
int N;
fin >> N;
for (int i = 1; i <= N; i++)
{
int opt, val;
fin >> opt >> val;
switch (opt)
{
case 1:
insert(val);
break;
case 2:
remove(val);
break;
case 3:
fout << find(val) << endl;
}
}
return 0;
}