Pagini recente » Cod sursa (job #3234310) | Cod sursa (job #1903609) | Cod sursa (job #647221) | Cod sursa (job #457203) | Cod sursa (job #1701609)
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
vector <int> a[666013];
vector <int>::iterator it;
int main()
{
FILE *fin, *fout;
int n, i, op, x, restul, semafor;
fin = fopen("hashuri.in", "r");
fout = fopen("hashuri.out", "w");
fscanf(fin, "%d", &n);
for(i = 0; i < n; i++)
{
fscanf(fin, "%d%d", &op, &x);
if(op == 1)
{
restul = x % 666013;
semafor = 1;
for(it = a[restul].begin(); it != a[restul].end(); it++)
if(*it == x)
{
semafor = 0;
it = a[restul].end() - 1;
}
if(semafor == 1)a[restul].push_back(x);
}
if(op == 2)
{
restul = x % 666013;
for(it = a[restul].begin(); it != a[restul].end(); it++)
if(*it == x)
{
a[restul].erase(it);
it = a[restul].end() - 1;
}
}
if(op == 3)
{
restul = x %666013;
semafor = 0;
for(it = a[restul].begin(); it != a[restul].end(); it++)
if(*it == x)
{
semafor = 1;
it = a[restul].end() - 1;
}
fprintf(fout, "%d\n", semafor);
}
}
fclose(fin);
fclose(fout);
return 0;
}