Pagini recente » Cod sursa (job #2368828) | Cod sursa (job #1595639) | Cod sursa (job #2143466) | Cod sursa (job #2710199) | Cod sursa (job #1049307)
#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)
{
R[k].erase(R[k].begin()+poz);
}
}
if(op==3)
{
poz=cauta(x);
if(poz==-1)
o<<0;
else
o<<1;
o<<'\n';
}
n--;
}
return 0;
}