Pagini recente » Cod sursa (job #1600972) | Cod sursa (job #3191176) | Cod sursa (job #3133645) | Cod sursa (job #277580) | Cod sursa (job #1772431)
#include <fstream>
#define prm 101
using namespace std;
ifstream in ("hashuri.in");
ofstream out("hashuri.out");
const int mod = 1 << 2;
int h[mod], n ,tp, mamaliga;
void son(int &poz)
{
if(++poz == mod)
poz = 0;
}
int bul(int x)
{
int poz = (1LL * x * prm) % mod;
while(h[poz] != x && h[poz] != 0)
{
son(poz);
}
if(h[poz] == x)
return poz;
else
return -1;
}
void ekle(int x)
{
if(bul(x) != 1)
return;
int poz = (1LL * x * prm) % mod;
while(h[poz] != x && h[poz] != 0)
{
son(poz);
}
h[poz] = x;
}
void sil(int x)
{
int poz = bul(x);
if(poz != -1)
{
h[poz] = -1;
}
}
int main()
{
in >> n;
for(;n > 0; --n)
{
in >> tp >> mamaliga;
if(tp == 1)
ekle(mamaliga);
else if(tp = 2)
sil(mamaliga);
else if(bul(mamaliga) == -1)
out << 0 << "\n";
else
out << 1 << "\n";
}
}