Pagini recente » Cod sursa (job #885054) | Cod sursa (job #3236044) | Cod sursa (job #1315750) | Cod sursa (job #1974483) | Cod sursa (job #2746442)
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int n;
vector<int> hashMap[666013];
inline vector<int>::iterator findVal(int x)
{
int lista = x % 666013;
vector<int>::iterator it;
for(it = hashMap[lista].begin(); it != hashMap[lista].end(); it++){
if(*it == x) {
return it;
}
}
return hashMap[lista].end();
}
inline void insertVal(int x)
{
int lista = x % 666013;
if(findVal(x) == hashMap[lista].end()){
hashMap[lista].push_back(x);
}
}
inline void eraseVal(int x)
{
int lista = x % 666013;
vector<int>::iterator it = findVal(x);
if(it != hashMap[lista].end()){
hashMap[lista].erase(it);
}
}
int main()
{
int op, x;
ifstream f("hashuri.in");
ofstream o("hashuri.out");
f >> n;
for(int i = 0; i < n; i++){
f >> op >> x;
if(op == 1){
insertVal(x);
continue;
}
if(op == 2){
eraseVal(x);
continue;
}
if(op == 3){
cout << (findVal(x) != hashMap[x % 666013].end()) << "\n";
}
}
return 0;
}