Pagini recente » Cod sursa (job #505040) | Monitorul de evaluare | Cod sursa (job #67848) | Cod sursa (job #1353544) | Cod sursa (job #1573984)
#include <iostream>
#include <set>
#include <vector>
#include <fstream>
#include <stdio.h>
#define MOD 666013
using namespace std;
ifstream f("hashuri.in");
int N;
vector<int> Hash[MOD];
inline vector<int>::iterator Find_Value(int x)
{
int poz = x % MOD;
vector<int>::iterator it;
for (it = Hash[poz].begin(); it != Hash[poz].end(); ++it)
if (*it == x) return it;
return Hash[poz].end();
}
inline void Insert_Value(int x)
{
int poz = x % MOD;
if (Find_Value(x) == Hash[poz].end())
Hash[poz].push_back(x);
}
inline void Erase_Value(int x)
{
int poz = x % MOD;
vector<int>::iterator it = Find_Value(x);
if (it != Hash[poz].end())
Hash[poz].erase(it);
}
int main(){
freopen("hashuri.out", "w", stdout);
int Operation,Value;
f>>N;
for(int i=1;i<=N;i++){
f>>Operation>>Value;
if(Operation==1){
Insert_Value(Value);
continue;
}
if(Operation==2){
Erase_Value(Value);
continue;
}
printf("%d\n", Find_Value(Value) != Hash[Value % MOD].end());
}
}