Pagini recente » Cod sursa (job #1101975) | Cod sursa (job #1286557) | Cod sursa (job #930426) | Cod sursa (job #2728345) | Cod sursa (job #1197000)
using namespace std;
#include <fstream>
#include <vector>
#include <algorithm>
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int Nmax = 1000000;
const int P = 666013;
vector<int> L[P];
void push(int) ;
void sterge(int) ;
bool search1(int) ;
int main()
{
int i, a, tip, n;
fin>>n;
for(i=0; i<n; ++i)
{
fin>>tip>>a;
if(tip==1) push(a);
if(tip==2) sterge(a);
if(tip==3) fout<<search1(a)<<'\n';
}
return 0;
}
void push(int x)
{
int hash = x%P;
for(vector<int>::iterator it = L[hash].begin(); it!=L[hash].end(); ++it)
if(*it == x) return;
L[hash].push_back(x);
}
void sterge(int x)
{
int hash = x%P;
for(vector<int>::iterator it = L[hash].begin(); it!=L[hash].end(); ++it)
if(*it == x)
{
L[hash].erase(it);
return;
}
}
bool search1(int x)
{
int hash = x%P;
for(vector<int>::iterator it = L[hash].begin(); it!=L[hash].end(); ++it)
if(*it == x) return 1;
return 0;
}