Pagini recente » Cod sursa (job #2601274) | Cod sursa (job #2042299) | Cod sursa (job #2872668) | Cod sursa (job #1789283) | Cod sursa (job #1412795)
#include<fstream>
#include<vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("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()
{
int q,nr;
f>>n;
while(n)
{
n--;
f>>q>>nr;
if(q==1)
ad(nr);
else if(q==2)
elim(nr);
else if(cauta(nr)!=-1)
g<<"1\n";
else
g<<"0\n";
}
}
int main()
{
rezolvare();
return 0;
}