Pagini recente » Cod sursa (job #2321165) | Cod sursa (job #717237) | Cod sursa (job #1939362) | Cod sursa (job #2684904) | Cod sursa (job #2806024)
#include <bits/stdc++.h>
#define mod 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n, x, y;
vector<int> ha[mod];
vector<int>::iterator find_place(int x)
{
int position = x;
while(position >= mod)
position -= mod;
for(vector<int>::iterator it = ha[position].begin();it != ha[position].end();++it)
if(*it == x)
return it;
return ha[position].end();
}
void add(int x)
{
int position = x;
while(position >= mod)
position -= mod;
vector<int>::iterator place = find_place(x);
if(place == ha[position].end())
ha[position].push_back(x);
}
void erase(int x)
{
int position = x;
while(position >= mod)
position -= mod;
vector<int>::iterator place = find_place(x);
if(place != ha[position].end())
ha[position].erase(place);
}
void read()
{
f>>n;
for(int i = 0;i < n;++i)
{
f>>x>>y;
if(x == 1)
add(y);
else if(x == 2)
erase(y);
else
g<<(find_place(y) != ha[y % mod].end())<<'\n';
}
f.close();
g.close();
}
int main()
{
read();
return 0;
}