Pagini recente » Cod sursa (job #2905564) | Cod sursa (job #1680887) | Cod sursa (job #717761) | Cod sursa (job #1832525) | Cod sursa (job #3230306)
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int mod = 666013;
int n;
vector<int> H[mod];
vector<int>::iterator it;
void v_find(int ind, int x)
{
for(it = H[ind].begin(); it != H[ind].end(); it ++)
if(*it == x)
return ;
}
void add(int ind, int x)
{
if(it == H[ind].end())
H[ind].push_back(x);
}
void out(int ind, int x)
{
if(it != H[ind].end())
H[ind].erase(it);
}
int verif(int ind)
{
return (it != H[ind].end() ? 1 : 0);
}
int main()
{
f >> n;
for(int i = 1; i <= n; i ++)
{
int op, x; f >> op >> x;
int ind = x % mod;
v_find(ind, x);
if(op == 1)
add(ind, x);
else if(op == 2)
out(ind, x);
else
g << verif(ind) << '\n';
}
return 0;
}