Pagini recente » Cod sursa (job #806088) | Cod sursa (job #535491) | Cod sursa (job #879823) | Cod sursa (job #2139601) | Cod sursa (job #1003296)
#include <iostream>
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
int n;
vector<int> l[MOD];
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector<int>::iterator gaseste(int x)
{
int list = x % MOD;
vector<int>::iterator it;
for(it=l[list].begin();it!=l[list].end();it++)
{
if(*it==x)
{
return it;
}
}
return l[list].end();
}
void adauga(int x)
{
int list = x % MOD;
if(gaseste(x) == l[list].end())
l[list].push_back(x);
}
void sterge(int x)
{
int list = x % MOD;
vector<int>::iterator it = gaseste(x);
if(it!=l[list].end())
{
l[list].erase(it);
}
}
int main(int argc, char** argv)
{
int op;
int x;
f>>n;
for(int i=0;i<n;i++)
{
f>>op;
f>>x;
if(op==1)
{
adauga(x);
}
if(op==2)
{
sterge(x);
}
if(op==3)
{
bool d = gaseste(x) != l[x % MOD].end();
g<<d<<"\n";
}
}
f.close();
g.close();
return 0;
}