Pagini recente » Cod sursa (job #449017) | Cod sursa (job #3185411) | Cod sursa (job #1455194) | Borderou de evaluare (job #2018423) | Cod sursa (job #644278)
Cod sursa(job #644278)
#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 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=existenta(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;
if(instructiune==1)
inserare(numar,cheia);
else
if(instructiune==2)
stergere(numar,cheia);
else
if(instructiune==3)
{
if(existenta(numar,cheia)==-1)
g<<0<<endl;
else
g<<1<<endl;
}
}
}
int main()
{
citire();
f.close();
g.close();
return 0;
}