Pagini recente » Cod sursa (job #1773250) | Cod sursa (job #2880261) | Cod sursa (job #1805678) | Cod sursa (job #2868084) | Cod sursa (job #1644915)
#include<fstream>
#include<vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,op,nr;
vector<int> a[666013];
int poz(int x)
{
return x%666013;
}
int caut(int x)
{
int y=poz(x);
for(int i=a[y].size()-1;i>=0;i--)
if(a[y][i]==x)
return i;
return -1;
}
void ad(int x)
{
if(caut(x)==-1)
a[poz(x)].push_back(x);
}
void elim(int x)
{
int p=caut(x);
if(p!=-1)
{
swap(a[poz(x)][p],a[poz(x)].back());
a[poz(x)].pop_back();
}
}
void afis(int x)
{
if(caut(x)==-1)
g<<0<<"\n";
else
g<<1<<"\n";
}
int main()
{
f>>n;
while(n)
{
n--;
f>>op>>nr;
if(op==1)
ad(nr);
else if(op==2)
elim(nr);
else if(op==3)
afis(nr);
}
}