Pagini recente » Cod sursa (job #3210019) | Cod sursa (job #932276) | Cod sursa (job #1635223) | Cod sursa (job #393928) | Cod sursa (job #1235792)
#include <fstream>
#include <vector>
const int MOD=666013;
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector < int > V[MOD];
int N;
vector <int> :: iterator find(int Value)
{
int List=Value%MOD;
for(vector <int> :: iterator it = V[List].begin();it!=V[List].end();it++)
if(*it == Value)
return it;
return V[List].end();
}
void Insert(int Value)
{
int List=Value%MOD;
if (find(Value)==V[List].end())
V[List].push_back(Value);
}
void Delete(int Value)
{
int List=Value%MOD;
vector <int> :: iterator it = find(Value);
if (it!=V[List].end())
V[List].erase(it);
}
void read()
{
int op, x;
fin >> N;
for(int i = 1; i <= N; i++)
{
fin >> op >> x;
if(op == 1)
{
Insert(x);
}
if(op == 2)
{
Delete(x);
}
if(op == 3)
{
fout<< (find(x)!=V[x%MOD].end()) <<'\n';
}
}
}
int main()
{
read();
return 0;
}