Pagini recente » Cod sursa (job #2581745) | Cod sursa (job #2186132) | Cod sursa (job #2386852) | Cod sursa (job #1182868) | Cod sursa (job #2225343)
#include <iostream>
#include <vector>
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)
{
cout<<"1"<<endl;
return;
}
cout<<"0"<<endl;
}
int main()
{
int n, x, op;
cin>>n;
for(;n;n--)
{
cin>>op>>x;
if(op == 1)
inserare(x);
else
if(op == 2)
elimina(x);
else cauta(x);
}
return 0;
}