Pagini recente » Cod sursa (job #1051416) | Cod sursa (job #604346) | Cod sursa (job #630443) | Cod sursa (job #3242296) | Cod sursa (job #2051051)
#include <bits/stdc++.h>
using namespace std;
FILE *in,*out;
const int modulo = 666013;
vector <int> h[modulo];
bool cauta(int x)
{
if(h[x%modulo].size() > 0)
for(int i = 0 ;i < h[x%modulo].size() ;i ++)
if(h[x%modulo][i] == x)
return 1;
return 0;
}
void adauga(int x)
{
if(cauta(x) == 0)
h[x % modulo].push_back(x);
}
void sterge(int x)
{
vector<int>::iterator it;
for(it = h[x % modulo].begin(); it != h[x % modulo].end(); ++it) {
if(*it == x) {
h[x % modulo].erase(it);
return;
}
}
}
bool verifica(int x)
{
for(int i = 0 ;i < h[x%modulo].size() ;i ++) {
if(x == h[x%modulo][i])
return 1;
}
return 0;
}
int main()
{
in = fopen("hashuri.in","r");
out = fopen("hashuri.out","w");
int n;
fscanf(in,"%d",&n);
for(int i = 1;i <= n;i ++)
{
int t,x;
fscanf(in,"%d %d",&t,&x);
if(t == 1)
adauga(x);
if(t == 2)
sterge(x);
if(t == 3)
fprintf(out,"%d\n",verifica(x));
}
return 0;
}