Pagini recente » Cod sursa (job #1017715) | Cod sursa (job #207112) | Cod sursa (job #3161844) | Cod sursa (job #1157439) | Cod sursa (job #2886066)
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
#define k 666013
vector <int> hashh[k+5];
int main()
{
int n, i, j, x, y, clasa, poz, ok;
f>>n;
for(i = 1; i <= n; i++)
{
f>>y>>x;
ok = 0;
clasa = x % k;
for(j = 0; j < hashh[clasa].size(); j++)
{
if(hashh[clasa][j] == x)
{
ok = 1;
poz = j;
break;
}
}
if(y == 1)
{
if(ok == 0)
hashh[clasa].push_back(x);
}
else
{
if(y == 2)
{
if(ok == 1)
{
swap(hashh[clasa][poz], hashh[clasa].back());
hashh[clasa].pop_back();
}
}
else
{
g<<ok<<endl;
}}
}
return 0;
}