Pagini recente » Cod sursa (job #699827) | Cod sursa (job #1549362) | Cod sursa (job #751723) | Cod sursa (job #2561021) | Cod sursa (job #2634312)
#include <iostream>
#include <fstream>
#include <vector>
#define MOD 69420
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
vector <int> hsh[69420];
int q, cer, xx, ind;
int isinhash(int x)
{
for(int i=0; i<hsh[x%MOD].size(); i++)
if(hsh[x%MOD][i]==x) return i;
return -1;
}
int main()
{
in>>q;
while(q--)
{
in>>cer>>xx;
switch(cer)
{
case 1:
ind=isinhash(xx);
if(ind==-1) hsh[xx%MOD].push_back(xx);
break;
case 2:
ind=isinhash(xx);
if(ind>=0) hsh[xx%MOD].erase(hsh[xx%MOD].begin()+ind);
break;
case 3:
ind=isinhash(xx);
if(ind>=0) out<<"1\n";
else out<<"0\n";
break;
}
}
return 0;
}