Pagini recente » Cod sursa (job #504574) | Cod sursa (job #1180082) | Cod sursa (job #1604412) | Cod sursa (job #2631239) | Cod sursa (job #1038077)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector <int>h[666013];
int n,val,tip;
int cauta(int x)
{
int unde=x%666013;
for(int i=0;i<h[unde].size();i++)
if(h[unde][i]==x)
return 1;
return 0;
}
void insereaza(int x)
{
if(cauta(x)>0)
return;
h[x%666013].push_back(x);
}
void sterge(int x)
{
int y=cauta(x);
if(y==0)
return;
h[x%666013][y]=h[x%666013][h[x%666013].size()-1];
h[666013].resize(h[x%666013].size()-1);
}
int main()
{
f>>n;
for(int i=1;i<=n;i++)
{
f>>tip>>val;
if(tip==1)
g<<cauta(val)<<endl;
if(tip==2)
insereaza(val);
if(tip==3)
sterge(val);
}
f.close();
g.close();
return 0;
}