Pagini recente » Cod sursa (job #2281942) | Cod sursa (job #1819165) | Cod sursa (job #2697120) | Cod sursa (job #1239180) | Cod sursa (job #1641380)
#include<iostream>
#include<fstream>
#include<vector>
#define MOD 123457
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
vector <int> L[MOD+2];
void Adauga(int x)
{
int R, gasit, j;
R = x%MOD;
gasit = 0;
for (j=0; j<L[R].size() && !gasit; j++)
{
if (L[R][j] == x) gasit=1;
}
if (!gasit) L[R].push_back(x);
}
void Sterge(int x)
{
int R, j;
R = x%MOD;
for (j=0; j<L[R].size(); j++)
{
if (L[R][j] == x)
{ L[R][j] = L[R][L[R].size()-1];
L[R].pop_back();
}
}
}
int Cauta(int x)
{
int R, j;
R = x%MOD;
for (j=0; j<L[R].size(); j++)
if (L[R][j] == x)
return 1;
return 0;
}
int main ()
{
int T, tip, x;
fin >> T;
for (int i=1; i<=T; i++)
{
fin >> tip;
if (tip == 1)
{
fin >> x;
Adauga(x);
}
else if (tip == 2)
{
fin >> x;
Sterge(x);
}
else
{
fin >> x;
fout << Cauta(x) << "\n";
}
}
fin.close();
fout.close();
return 0;
}