Pagini recente » Cod sursa (job #3190112) | Cod sursa (job #1176328) | Cod sursa (job #583072) | Cod sursa (job #1757933) | Cod sursa (job #2194747)
#include <iostream>
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int N;
vector<int> G[MOD];
vector<int>::iterator findValue(int x)
{
int l = x%MOD;
for(vector<int>::iterator it = G[l].begin(); it != G[l].end(); it++)
if (*it == x)
return it;
return G[l].end();
}
void insertValue(int x)
{
int l = x % MOD;
if (findValue(x) == G[l].end())
G[l].push_back(x);
}
void deleteValue(int x)
{
int l = x % MOD;
vector<int>::iterator it = findValue(x);
if (it != G[l].end())
G[l].erase(it);
}
int main()
{
fin>>N;
int op,x;
for(int i=1;i<=N;i++)
{
fin>>op>>x;
if (op == 1)
{
insertValue(x);
continue;
}
if (op == 2)
{
deleteValue(x);
continue;
}
fout<<(findValue(x) != G[x%MOD].end())<<'\n';
}
return 0;
}