Pagini recente » Cod sursa (job #2514511) | Cod sursa (job #208241) | Cod sursa (job #3249139) | Cod sursa (job #43354) | Cod sursa (job #2894695)
#include <fstream>
#include<vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector<int> myhash[666015];
int main()
{
int k=666013;
int n, operatie, element,j;
f>>n;
int clasa;
for(int i=1;i<=n;i++)
{f>>operatie>>element;
clasa=element%k;
int found=0;
for(j=0;j<myhash[clasa].size();j++)
if (myhash[clasa][j]==element)
{
found = 1;
break;
}
if(operatie==1)
{ if (found==0)
myhash[clasa].push_back(element);
}
if(operatie==2)
{ if (found==1)
{
swap(myhash[clasa][j], myhash[clasa].back());
myhash[clasa].pop_back();
}
}
if(operatie==3)
{
g<<found<<'\n';
}
}
}