Pagini recente » Cod sursa (job #927930) | Cod sursa (job #2375076) | Cod sursa (job #1907101) | Cod sursa (job #1610374) | Cod sursa (job #1600535)
#include <fstream>
#define MOD 666013
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector<int> h[MOD+10];
int n,i,j,op,x;
int hh(int x)
{
return x%MOD;
}
int check(int cheie, int x)
{
int aux;
for (vector<int>::iterator it = h[cheie].begin(); it != h[cheie].end(); it ++)
{
aux = *it;
if (aux == x)
return 1;
}
return 0;
}
void del(int cheie, int x)
{
int aux;
for (vector<int>::iterator it = h[cheie].begin(); it != h[cheie].end(); it ++)
{
aux = *it;
if (aux == x)
{
h[cheie].erase(it);
return;
}
}
}
void ins(int cheie, int x)
{
if (!check(hh(x),x))
h[cheie].push_back(x);
}
int main()
{
fin>>n;
for (i=1;i<=n;i++)
{
fin>>op>>x;
if (op == 1)
ins(hh(x),x);
if (op == 2)
del(hh(x),x);
if (op == 3)
fout<<check(hh(x),x)<<"\n";
}
return 0;
}