Pagini recente » Istoria paginii utilizator/andreicoravu | Diferente pentru utilizator/stargold2 intre reviziile 162 si 161 | Monitorul de evaluare | Monitorul de evaluare | Cod sursa (job #2225344)
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
const int modulo = 100019;
vector<int> v[modulo];
void inserare(int x)
{
int r = x % modulo;
for(auto it : v[r])
if(it == x) return;
v[r].push_back(x);
}
void elimina(int x)
{
int r = x % modulo;
for(vector<int>::iterator it = v[r].begin(); it != v[r].end(); it++)
if (*it == x)
{
swap(*it, v[r].back());
v[r].pop_back();
return;
}
}
void cauta(int x)
{
int r = x % modulo;
for(auto it : v[r])
if(it == x)
{
printf("1\n");
return;
}
printf("0\n");
}
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int n, x, op;
scanf("%d", &n);
for(;n;n--)
{
scanf("%d%d", &op, &x);
if(op == 1)
inserare(x);
else
if(op == 2)
elimina(x);
else cauta(x);
}
return 0;
}