Pagini recente » Cod sursa (job #39245) | Cod sursa (job #2658691) | Cod sursa (job #16173) | Cod sursa (job #1642240) | Cod sursa (job #1971200)
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
ifstream f ("hashuri.in");
ofstream g ("hashuri.out");
vector <int> v[666014];
int y,n,j,caz,nr,poz;
int usu(int x)
{
return x%MOD;
}
int caut(int x)
{
y=usu(x);
for(int i=0;i<v[y].size();++i) if(v[y][i]==x) return i;
return -1;
}
void bag(int x)
{
y=usu(x);
if(caut(x)==-1) v[y].push_back(x);
}
void scot(int t)
{
int p=usu(t);
if(caut(t)>=0)
{
poz=caut(t);
v[p].erase(v[p].begin()+poz,v[p].begin()+poz+1);
}
}
int main()
{
f>>n;
for(j=1;j<=n;++j)
{
f>>caz>>nr;
if(caz==1) bag(nr);
else if(caz==2) scot(nr);
else
{
if(caut(nr)==-1) g<<0<<'\n';
else g<<1<<'\n';
}
}
}