Pagini recente » Cod sursa (job #1028459) | Cod sursa (job #553551) | Cod sursa (job #2332377) | Cod sursa (job #369487) | Cod sursa (job #2483077)
#include <iostream>
#include <fstream>
#include <list>
#include <algorithm>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
#define mod 666013
list<int> H[mod];
void add(int x)
{
int address = x % mod;
if (find(H[address].begin(), H[address].end(), x) == H[address].end())
H[address].push_back(x);
}
void remove(int x)
{
int address = x % mod;
H[address].remove(x);
}
int has(int x)
{
int address = x % mod;
list<int>::iterator it = find(H[address].begin(), H[address].end(), x);
if (it != H[address].end()) return 1;
return 0;
}
int main()
{
int n, o, x;
fin >> n;
for (int i = 1; i <= n; ++i)
{
fin >> o >> x;
if (o == 1) add(x);
else if (o == 2) remove(x);
else fout << has(x) << "\n";
}
return 0;
}