Pagini recente » Cod sursa (job #3244269) | Cod sursa (job #2337059) | Cod sursa (job #520590) | Cod sursa (job #186105) | Cod sursa (job #941219)
Cod sursa(job #941219)
#include <fstream>
#include <algorithm>
#include <set>
#define In "hashuri.in"
#define Out "hashuri.out"
#define mod 666013
using namespace std;
set<int>Hash[mod+1];
inline bool Cauta(int x)
{
int y = x%mod;
set<int>::iterator it;
it = lower_bound(Hash[y].begin(),Hash[y].end(),x);
return (*it==x);
}
inline void Adauga(int x)
{
int y = x%mod;
Hash[y].insert(x);
}
inline void Sterge(int x)
{
int y = x%mod;
Hash[y].erase(x);
}
int main()
{
int i,n,op,x;
ifstream f(In);
ofstream g(Out);
f>>n;
for(i=1;i<=n;i++)
{
f>>op>>x;
if(op==1)
Adauga(x);
else
{
if(op==2)
Sterge(x);
else
g<<Cauta(x)<<"\n";
}
}
f.close();
g.close();
return 0;
}