Pagini recente » Cod sursa (job #1264463) | Cod sursa (job #1607207) | Cod sursa (job #2600651) | Cod sursa (job #2905719) | Cod sursa (job #2744963)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int MOD = 666013;
vector<int> M[MOD];
vector<int>::iterator Cautare(int x)
{
int list = x % MOD;
vector<int>::iterator it;
for (it=M[list].begin();it != M[list].end(); it++)
if (*it == x)
return it;
return M[list].end();
}
void Inserare(int x)
{
int list = x % MOD;
if (Cautare(x) == M[list].end())
M[list].push_back(x);
}
void Stergere(int x)
{
int list = x % MOD;
vector<int>::iterator it = Cautare(x);
if (it != M[list].end())
M[list].erase(it);
}
int main()
{
int n,op,x;
fin>>n;
for (int i=0;i<n;i++)
{
fin>>op>>x;
if (op == 1) Inserare(x);
else if (op == 2) Stergere(x);
else if (op == 3)
{
if (Cautare(x) != M[x % MOD].end())
fout<<1<<endl;
else fout<<0<<endl;
}
}
fin.close();
fout.close();
return 0;
}