Pagini recente » Cod sursa (job #335069) | Cod sursa (job #3154244) | Cod sursa (job #2958895) | Cod sursa (job #2246274) | Cod sursa (job #2893684)
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
int n, i, x, op, ok, j, vSize;
vector<vector<int>> hashMatrix(666013); //avem cate o lista pentru fiecare rest de la 0 la p - 1
int main()
{
in>>n;
for(i = 1; i <= n; i++)
{
in>>op>>x;
if(op == 1)
{
ok = 0;
vSize = hashMatrix[x % 666013].size();
for(j = 0; j < vSize; j++)
if(hashMatrix[x % 666013][j] == x)
{
ok = 1;
break;
}
if(!ok)
hashMatrix[x % 666013].push_back(x);
}
else if(op == 2)
{
vSize = hashMatrix[x % 666013].size();
for(j = 0; j < vSize; j++)
if(hashMatrix[x % 666013][j] == x)
{
hashMatrix[x % 666013][j] = 0;
break;
}
}
else
{
ok = 0;
vSize = hashMatrix[x % 666013].size();
for(j = 0; j < vSize; j++)
if(hashMatrix[x % 666013][j] == x)
{
ok = 1;
break;
}
out<<ok<<endl;
}
}
return 0;
}