Pagini recente » Cod sursa (job #237002) | Cod sursa (job #2816761) | Cod sursa (job #1448235) | Cod sursa (job #1132597) | Cod sursa (job #3129038)
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
int p = 666103;
int n, x, y;
int main()
{
vector<vector<int>> hash(666103);
in >> n;
for (int j = 0; j < n; j++)
{
in >> x >> y;
if (x == 1)
{ /// inserare
int k = y % p;
hash[k].push_back(y);
}
else if (x == 2)
{ /// delete
int k = y % p;
int aux = hash[k].size();
int ok = 0;
for (int i = 0; i < aux; i++)
{
if (hash[k][i] == y)
{
ok = 1;
}
if (ok == 1)
{
if(i==aux-1)
hash[k].resize(i);
else
hash[k][i] = hash[k][i + 1];
}
}
}
else
{
int k = y % p;
int ok=0;
int aux = hash[k].size();
for (int i = 0; i < aux; i++)
if (hash[k][i] == y)
{ ok=1;break;}
if(ok)
out<<1<<endl;
else
out<<0<<endl; }
}
return 0;
}