Pagini recente » Cod sursa (job #2600088) | Cod sursa (job #2125070) | Cod sursa (job #3130101) | Cod sursa (job #887210) | Cod sursa (job #806455)
Cod sursa(job #806455)
#include <iostream>
#include <vector>
#include <cstdio>
#define BIG 666001
using namespace std;
vector <long long> hash[BIG];
bool find(long long x)
{
long mod = x % BIG;
for (int i=0;i<hash[mod].size();i++)
{
if (hash[mod][i] == x) return true;
}
return false;
}
void add(long long x)
{
long mod = x % BIG;
if (!find(x))
{
hash[mod].push_back(x);
}
}
void erase(long long x)
{
long mod = x % BIG;
if (find(x))
{
hash[mod].erase(x);
}
}
int main()
{
FILE *input = fopen("hashuri.in","r");
FILE *output = fopen("hashuri.out","w");
long n;
fscanf(input,"%ld",&n);
for (long i=0;i<n;i++)
{
int op;
long long x;
fscanf(input,"%d%lld",&op,&x);
if (op == 1)
{
add(x);
}
if (op == 2)
{
erase(x);
}
if (op == 3)
{
fprintf(output,"%d\n",find(x));
}
}
fclose(input);
fclose(output);
return 0;
}