Pagini recente » Cod sursa (job #1818849) | Cod sursa (job #463607) | Istoria paginii utilizator/anabellamaria | Cod sursa (job #2672584) | Cod sursa (job #1049300)
#include <fstream>
#include <vector>
#define M 50000
using namespace std;
ifstream in("hashuri.in");
ofstream o("hashuri.out");
vector <int> R[50000];
int n,k;
int cauta(int x)
{
int i,lg;
k=x%M;
lg=R[k].size();
for(i=0;i<lg;i++)
{
if(R[k][i]==x)
return i;
}
return -1;
}
int main()
{
int x,op,poz;
in>>n;
while(n)
{
in>>op>>x;
if(op==1)
{
if(cauta(x)==-1)
{
R[k].push_back(x);
}
}
if(op==2)
{
poz=cauta(x);
if(poz!=-1)
{
if(poz)
{
R[k].erase(R[k].begin()+poz-1,R[k].begin()+poz);
}
else
R[k].erase(R[k].begin());
}
}
if(op==3)
{
poz=cauta(x);
if(poz==-1)
o<<0;
else
o<<1;
o<<'\n';
}
n--;
}
return 0;
}