Pagini recente » Cod sursa (job #2681848) | Monitorul de evaluare | Cod sursa (job #1555814) | Cod sursa (job #352646) | Cod sursa (job #777312)
Cod sursa(job #777312)
#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;
x %= MOD;
for (it = hash[x].begin (); it != hash[x].end (); ++it)
if (*it == x)
return it;
return hash[x].end ();
}
inline void insert (int x)
{
int x2 = x % MOD;
if (find (x2) != 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;
}