Pagini recente » Statistici Giurgiu Adrian (j8rj72) | Cod sursa (job #2105544) | Istoria paginii runda/lucian_blaga_cls_10/clasament | Cod sursa (job #88943) | Cod sursa (job #777314)
Cod sursa(job #777314)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream in ("hashuri.in");
ofstream out ("hashuri.out");
const int MOD = 666013;
vector <int> hash[MOD + 1];
inline vector <int> :: iterator find (int x)
{
vector <int> :: iterator it;
int x2 = x % MOD;
for (it = hash[x2].begin (); it != hash[x2].end (); ++it)
if (*it == x)
return it;
return hash[x2].end ();
}
inline void insert (int x)
{
int x2 = x % MOD;
if (find (x) == hash[x2].end ())
hash[x2].push_back (x);
}
inline void del (int x)
{
int x2 = x % MOD;
vector <int> :: iterator it = find (x);
if (it != hash[x2].end ())
hash[x2].erase (it);
}
int main ()
{
int N, tip, x;
for (in >> N; N; -- N){
in >> tip >> x;
if (tip == 1)
insert (x);
if (tip == 2)
del (x);
if (tip == 3)
out << (find (x) != hash[x % MOD].end ()) << "\n";
}
return 0;
}