Pagini recente » Cod sursa (job #1503956) | Cod sursa (job #137598) | Cod sursa (job #1696057) | Cod sursa (job #2956802) | Cod sursa (job #1047943)
#include <fstream>
#include <vector>
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
const int zone=666013;
vector<int> h[zone];
int t, x, n, i;
int cautare(vector<int>h[zone], int x)
{
int p=x%zone;
for(i=0; i<h[p].size(); ++i)
if(h[p][i]==x) return i;
return -1;
}
void inserare(vector<int>h[zone], int x)
{
if(cautare(h, x)!=-1) return;
int p=x%zone;
h[p].push_back(x);
}
void del(vector<int>h[zone], int x)
{
int z=cautare(h, x);
if(z==-1) return;
int p=x%zone;
h[p][z]=h[p].back();
h[p].pop_back();
}
int main()
{
cin>>n;
for(i=1; i<=n; i++)
{
cin>>t>>x;
if(t==1) inserare(h, x);
else
if(t==2) del(h, x);
else
if(t==3) cout<<(cautare(h, x)!=-1)<<'\n';
}
return 0;
}