Pagini recente » Cod sursa (job #924719) | Cod sursa (job #2541390) | Cod sursa (job #788645) | Cod sursa (job #155786) | Cod sursa (job #1573979)
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
vector <int> H[100000];
void op1(int x)
{
int rest=x%100000;
for(int i=0; i<H[rest].size(); i++)
{
if(H[rest][i]==x)
return;
}
H[rest].push_back(x);
}
void op2(int x)
{
int rest=x%100000;
for(int i=0; i<H[rest].size(); i++)
{
if(H[rest][i]==x)
{
H[rest][i]=H[rest][H[rest].size()-1];
H[rest].pop_back();
return ;
}
}
}
bool op3(int x)
{
int rest=x%100000;
for(int i=0; i<H[rest].size(); i++)
if(H[rest][i]==x)
return 1;
return 0;
}
int main()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,operatie,x;
f>>n;
for(int i=1;i<=n;i++)
{
f>>operatie>>x;
if(operatie==1)
op1(x);
if(operatie==2)
op2(x);
if(operatie==3)
g<<op3(x)<<"\n";
}
f.close();
g.close();
return 0;
}