Pagini recente » Cod sursa (job #1624485) | Cod sursa (job #2998852) | Cod sursa (job #1427889) | Cod sursa (job #1669009) | Cod sursa (job #2886058)
#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;
bool 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;
break;
}
}
if(y == 1)
{
if(ok == 0)
hashh[clasa].push_back(x);
}
else
{
if(y == 2)
{
if(ok == 1)
{
swap(hashh[clasa][j],hashh[clasa].back());
hashh[clasa].pop_back();
}
}
else
{
if(ok == 1)
g<<1<<endl;
else
g<<0<<endl;
}}
}
return 0;
}