Pagini recente » Clasament probleme_oji_2 | Cod sursa (job #2122617) | Cod sursa (job #2382525) | Cod sursa (job #2130657) | Cod sursa (job #2748041)
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream o("hashuri.out");
#define mod 666013
vector<int> v[mod];
vector<int>::iterator findv(int x)
{
int xh = x % mod;
vector<int>::iterator it;
for (it = v[xh].begin(); it != v[xh].end(); it++)
if (*it == x)
return it;
return v[xh].end();
}
void insertv(int x)
{
int xh = x % mod;
if (findv(x) == v[xh].end())
v[xh].push_back(x);
}
void deletev(int x)
{
int xh = x % mod;
vector<int>::iterator it = findv(x);
if (it != v[xh].end())
v[xh].erase(it);
}
int main()
{
int N, op, x;
f >> N;
for (int 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;
}
}
}