Pagini recente » Cod sursa (job #2904562) | Cod sursa (job #874558) | Istoria paginii runda/simulare_republicana_4 | Cod sursa (job #2827880) | Cod sursa (job #2748021)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream o("hashuri.out");
const int mod=666013;
int N, op,x,i;
vector<int> v[mod];
vector<int>::iterator findv(int x)
{
int x_h = x % mod;
vector<int>::iterator it;
for (it = v[x_h].begin(); it != v[x_h].end(); ++it)
if (*it == x)
return it;
return v[x_h].end();
}
void insertv(int x)
{
int x_h = x % mod;
if (findv(x)==v[x_h].end())
v[x_h].push_back(x);
}
void deletev(int x)
{
int x_h = x % mod;
vector<int>::iterator it=findv(x);
if (v[x_h].end() != it)
v[x_h].erase(it);
}
int main()
{
f >> N;
for (i = 0; i < N; i++)
{
f >> op >> x;
if (op == 1)
insertv(x);
else if (op == 2)
deletev(x);
else
if( findv(x) == v[x % mod].end())
o<<'0'<<endl;
else
o<<'1'<<endl;
}
}