Pagini recente » Cod sursa (job #495391) | Cod sursa (job #1549309) | Cod sursa (job #559491) | Cod sursa (job #833877) | Cod sursa (job #1051975)
#include <fstream>
#include <vector>
#define M 666013
#define pb push_back
using namespace std;
vector <int> h[M];
vector <int> :: iterator it;
int x, ind;
vector <int> :: iterator gaseste ()
{
for (it = h[ind].begin (); it != h[ind].end (); it++)
if (*it == x) return it;
return it;
}
int main ()
{
ifstream f ("hashuri.in");
ofstream g ("hashuri.out");
int n;
f >> n;
for (int i = 1; i <= n; i++)
{
int op;
f >> op >> x;
ind = x % M;
it = gaseste ();
if (op == 1)
if (it == h[ind].end ()) h[ind].pb (x);
if (op == 2)
if (it != h[ind].end ()) h[ind].erase (it);
if (op == 3)
if (it != h[ind].end ()) g << "1\n";
else g << "0\n";
}
return 0;
}