Pagini recente » Cod sursa (job #2787943) | Cod sursa (job #2244856) | Cod sursa (job #391279) | Cod sursa (job #2458064) | Cod sursa (job #1171340)
#include <fstream>
#include <vector>
#define modulo 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector<int> hasht[modulo];
int n, i, op, x;
vector<int>::iterator hasht_find(int x) {
int list=x%modulo;
for (vector<int>::iterator it = hasht[list].begin(); it!=hasht[list].end(); it++)
if (*it == x)
return it;
return hasht[list].end();
}
void hasht_insert(int x) {
int list=x%modulo;
if (hasht_find(x) == hasht[list].end())
hasht[list].push_back(x);
}
void hasht_delete(int x) {
int list=x%modulo;
vector<int>::iterator it = hasht_find(x);
if (it!=hasht[list].end())
hasht[list].erase(it);
}
int main()
{
f>>n;
for (i=1; i<=n; i++) {
f>>op>>x;
if (op==1)
hasht_insert(x);
else if (op==2)
hasht_delete(x);
else
if (hasht_find(x) != hasht[x%modulo].end()) g<<1<<"\n";
else g<<0<<"\n";
}
return 0;
}