Pagini recente » Cod sursa (job #437610) | Cod sursa (job #229022) | Cod sursa (job #2343968) | Cod sursa (job #1125132) | Cod sursa (job #1399341)
#include<fstream>
#include<vector>
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
const int MOD = 666013;
int n,op,x;
vector<int> h[MOD];
void Insereaza(int x)
{
int y=x%MOD;
for (int i=0;i<h[y].size();i++)
if (h[y][i]==x) return;
h[y].push_back(x);
}
void Sterge(int x)
{
int y=x%MOD;
for (int i=0;i<h[y].size();i++)
if (h[y][i]==x){
swap(h[y][i],h[y][h[y].size()-1]);
h[y].pop_back();
}
}
int Cauta(int x)
{
int y=x%MOD;
for (int i=0;i<h[y].size();i++)
if (h[y][i]==x) return 1;
return 0;
}
int main()
{
cin>>n;
while (n--)
{
cin>>op>>x;
if (op==1)Insereaza(x);
if (op==2)Sterge(x);
if (op==3)cout<<Cauta(x)<<'\n';
}
return 0;
}