Pagini recente » Cod sursa (job #1940561) | Cod sursa (job #2766898) | Cod sursa (job #1808363) | Cod sursa (job #3186103) | Cod sursa (job #1410951)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n;
vector < vector < int > > V (666013);
inline int h(int &x)
{
return x%666013;
}
int cauta(int &x)
{
int y=h(x);
for(int i=V[y].size()-1; i>=0; i--)
if(V[y][i] == x)
return i;
return -1;
}
inline void ad(int &x)
{
if(cauta(x)!=-1)
return ;
V[h(x)].push_back(x);
}
inline void elim(int &x)
{
int p=cauta(x);
if(p==-1)
return ;
swap(V[h(x)][p],V[h(x)].back());
V[h(x)].pop_back();
}
void rezolvare()
{
//V.resize(666013);
int q,nr;
fin>>n;
while(n)
{
n--;
fin>>q>>nr;
if(q==1)
ad(nr);
else if(q==2)
elim(nr);
else if(cauta(nr) != -1)
fout<<"1\n";
else
fout<<"0\n";
}
}
int main()
{
rezolvare();
return 0;
}