Pagini recente » Cod sursa (job #1438282) | Cod sursa (job #2662944) | Cod sursa (job #2959249) | Cod sursa (job #304596) | Cod sursa (job #2272055)
#include <fstream>
#include <vector>
using namespace std;
ifstream fi("hashuri.in");
ofstream fo("hashuri.out");
const int MOD=100013;
int n,op,x;
vector <int> HASH[MOD];
void inserare(int x)
{
int rest=x%MOD;
int ok=0;
for(auto y: HASH[rest])
if(y==x)
ok=1;
if(ok==0)
HASH[rest].push_back(x);
}
void stergere(int x)
{
int rest=x%MOD;
for(auto (&it): HASH[rest])
if(it==x)
{
swap(it,HASH[rest][HASH[rest].size()-1]);
HASH[rest].pop_back();
break;
}
}
void afisare(int x)
{
int rest=x%MOD;
for(auto y:HASH[rest])
if(y==x)
{
fo<<1<<"\n";
return ;
}
fo<<0<<"\n";
}
int main()
{
fi>>n;
for(int i=1;i<=n;i++)
{
fi>>op>>x;
if(op==1)
inserare(x);
if(op==2)
stergere(x);
if(op==3)
afisare(x);
}
fi.close();
fo.close();
return 0;
}