Pagini recente » Cod sursa (job #799419) | Cod sursa (job #1596691) | Cod sursa (job #1291033) | Cod sursa (job #1942868) | Cod sursa (job #1564598)
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;
#define ll long long int
#define pb push_back
ifstream in ("hashuri.in");
ofstream out("hashuri.out");
const int nr_prim = 195931;
vector<ll> v[nr_prim];
ll modulo(int nr )
{
return nr % nr_prim;
}
void add(ll e)
{
if ( find(v[ modulo(e) ].begin(),v[modulo(e)].end(),e) != v[ modulo(e)].end())
return;
v[ modulo(e)].pb(e);
}
void erase(ll e)
{
if (find(v[ modulo(e) ].begin(),v[modulo(e)].end(),e) != v[ modulo(e)].end())
v[ modulo(e)].erase(find(v[ modulo(e) ].begin(),v[modulo(e)].end(),e));
}
int find(ll e)
{
if (find(v[ modulo(e) ].begin(),v[modulo(e)].end(),e) !=v[modulo(e)].end())
return 1;
return 0;
}
int main()
{
ll n,x,op;
in >> n;
for(int i = 0 ; i < n ; i ++)
{
in >> op >> x;
switch(op)
{
case 1: add(x); break;
case 2: erase(x); break;
case 3: out<<find(x)<<'\n' ; break;
}
}
return 0;
}