Pagini recente » Cod sursa (job #1681883) | Cod sursa (job #1058476) | Cod sursa (job #309626) | Cod sursa (job #1253889) | Cod sursa (job #1180014)
#include <fstream>
#include <vector>
using namespace std;
vector <int> v[666013];
vector<int>::iterator find(int x)
{
int rest=x%666013;
for (vector<int>::iterator it=v[rest].begin(); it!=v[rest].end(); ++it)
if (*it==x)
return it;
return v[rest].end();
}
void add(int x)
{
int rest=x % 666013;
if (find(x)==v[rest].end())
{
v[rest].push_back(x);
}
}
void remove(int x)
{
int rest=x%666013;
vector<int>::iterator it=find(x);
if (it!=v[rest].end())
v[rest].erase(it);
}
int main()
{
int n;
int type;
int x;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f>>n;
for (int i=1; i<=n; ++i)
{
f>>type>>x;
if (type==1)
{
add(x);
}
else
if (type==2)
{
remove(x);
}
else
{
int rest=x%666013;
int r=find(x)==v[rest].end()?0:1;
g<<r<<"\n";
}
}
return 0;
}