Pagini recente » Cod sursa (job #2048274) | Cod sursa (job #382105) | Cod sursa (job #566906) | Cod sursa (job #1097850) | Cod sursa (job #1997739)
#include <fstream>
#include <algorithm>
#define M 666013
using namespace std;
vector<int> v[M];
int h(int x){
return x % M;
}
bool src(int x){
return v[h(x)].end() != find(v[h(x)].begin(), v[h(x)].end(), x);
}
void del(int x){
if (src(x)){
auto pos = find(v[h(x)].begin(), v[h(x)].end(), x);
v[h(x)].erase(pos);
}
}
void ins(int x){
if (!src(x)){
v[h(x)].push_back(x);
}
}
int main()
{
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int op, x;
int N;
for (fin >> N; N; --N)
{
fin >> op >> x;
if (op == 1)
{
ins(x);
continue;
}
if (op == 2)
{
del(x);
continue;
}
fout << src(x) << '\n';
}
return 0;
}