Pagini recente » Cod sursa (job #2985677) | Borderou de evaluare (job #2007989) | Borderou de evaluare (job #2599388) | Cod sursa (job #1800120) | Cod sursa (job #644284)
Cod sursa(job #644284)
#include<vector>
#include<fstream>
#include<iostream>
using namespace std;
vector<long int>v[123460];
ifstream f("hashuri.in");
ofstream g("hashuri.out");
long int existenta(long int x,long int cheia)
{
long int i,lungime=v[cheia].size();
for(i=0;i<lungime;i++)
if(v[cheia][i]==x)
return 0;
return 1;
}
long int pozitie(long int x,long int cheia)
{
long int i,lungime=v[cheia].size();
for(i=0;i<lungime;i++)
if(v[cheia][i]==x)
return i;
return -1;
}
void inserare(long int x,long int cheia)
{
v[cheia].push_back(x);
}
void stergere(long int x,long int cheia)
{
long int poz,lungime=v[cheia].size();
poz=pozitie(x,cheia);
if(poz!=-1)
{
v[cheia][poz]=v[cheia][lungime-1];
v[cheia].pop_back();
}
}
void citire()
{
long int i,N,instructiune,numar,cheia;
f>>N;
for(i=1;i<=N;i++)
{
f>>instructiune;
f>>numar;
cheia=numar%123457;
switch(instructiune)
{
case 1:
inserare(numar,cheia);
break;
case 2:
stergere(numar,cheia);
break;
case 3:
g<<existenta(numar,cheia)<<endl;
break;
}
}
}
int main()
{
citire();
f.close();
g.close();
return 0;
}