Pagini recente » Cod sursa (job #403795) | Cod sursa (job #1994955) | Cod sursa (job #1570248) | Cod sursa (job #2834585) | Cod sursa (job #1053514)
#include <fstream>
#include <vector>
using namespace std;
#define numberOfZones 666013
ifstream in("hashuri.in");
ofstream out("hashuri.out");
vector < vector <int> > Hash(numberOfZones+1);
void INS(int value)
{
int zone = value % numberOfZones,ok=0,i;
for(i=0;i<Hash[zone].size();i++)
if(Hash[zone][i] == value)
ok = 1;
if(!ok)
Hash[zone].push_back(value);
}
void DEL(int value)
{
int zone = value % numberOfZones,i;
for(i=0;i<Hash[zone].size();i++)
if(Hash[zone][i]==value)
{
Hash[zone][i] = Hash[zone].back();
Hash[zone].pop_back();
}
}
int SCH(int value)
{
int zone = value % numberOfZones,i;
for(i=0;i<Hash[zone].size();i++)
if(Hash[zone][i]==value)
return 1;
return 0;
}
int main()
{
int n,op,x;
in>>n;
while(n--)
{
in>>op>>x;
if(op==1)
INS(x);
if(op==2)
DEL(x);
if(op==3)
out<<SCH(x)<<"\n";
}
return 0;
}