Pagini recente » Cod sursa (job #1624336) | Cod sursa (job #2642938) | Cod sursa (job #442902) | Cod sursa (job #1392664) | Cod sursa (job #1391584)
#include <cstdio>
#include <vector>
#define MOD 1000023
using namespace std;
FILE *fin, *fout;
int n, sizen, p, x, pos;
vector <int> hashn[MOD];
bool f;
int main()
{
fin = freopen("hashuri.in", "r", stdin);
fout = freopen("hashuri.out", "w", stdout);
scanf("%d", &n);
for(int t = 0; t< n; t++)
{
scanf("%d%d", &p, &x);
if(p == 1)
{
pos = x%MOD;
sizen = hashn[pos].size();
f = 0;
for(int i = 0; i< sizen; i++)
{
if(hashn[pos][i] == x) f = 1;
}
if(f == 0) hashn[pos].push_back(x);
}
if(p == 2)
{
pos = x%MOD;
sizen = hashn[pos].size();
for(int i = 0; i< sizen; i++)
{
if(hashn[pos][i] == x) hashn[pos][i] = -1;
}
}
if(p == 3)
{
pos = x%MOD;
sizen = hashn[pos].size();
f = 0;
for(int i = 0; i< sizen; i++)
{
if(hashn[pos][i] == x) f = 1;
}
printf("%d\n", f);
}
}
fclose(fin);
fclose(fout);
return 0;
}