Pagini recente » Cod sursa (job #2999337) | Cod sursa (job #497031) | Cod sursa (job #939416) | Cod sursa (job #226613) | Cod sursa (job #1085833)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
#define MOD 666013
#define cheie x%MOD
vector < int > vec[MOD];
int caut(int x)
{
for(int i = 0; i<vec[cheie].size(); i++)
if(vec[cheie][i]==x)
return i;
return -1;
}
void op1(int x)
{
if(caut(x) == -1)
vec[cheie].push_back(x);
}
void op2(int x)
{
int indice = caut(x);
if(indice != -1) {
swap(vec[cheie][indice],vec[cheie][vec[cheie].size()-1]);
vec[cheie].pop_back();
}
}
bool op3(int x)
{
if(caut(x) != -1)
return 1;
return 0;
}
int main()
{
int n, op, nr;
fin >> n;
for(int j = 1; j<=n; j++) {
fin >> op >> nr;
if(op==1)
op1(nr);
if(op==2)
op2(nr);
if(op==3)
fout << op3(nr) << "\n";
}
return 0;
}