Pagini recente » Cod sursa (job #1414450) | Cod sursa (job #1411719) | Cod sursa (job #2931959) | Cod sursa (job #1857088) | Cod sursa (job #2885577)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int k = 666013;
int main()
{
vector<vector<int> > hash1(k + 3);
int N;
int clasa, x, tipOp;
fin>>N;
for(int j = 0 ; j < N; ++j)
{
fin>>tipOp>>x;
if(tipOp == 1)
{
clasa = x % k;
hash1[clasa].push_back(x);
}
else
if(tipOp == 2)
{
clasa = x % k;
for(int i = 0; i < hash1[clasa].size(); ++i)
if(hash1[clasa][i] == x)
{
swap(hash1[clasa][i], hash1[clasa][hash1[clasa].size() - 1]);
hash1[clasa].pop_back();
}
}
else
if(tipOp == 3)
{
bool ok = 0;
clasa = x % k;
for(int i = 0; i < hash1[clasa].size(); ++i)
if(hash1[clasa][i] == x)
{
ok = 1;
fout<<'1'<<"\n";
break;
}
if(ok == 0)
fout<<'0'<<"\n";
}
}
return 0;
}