Pagini recente » Cod sursa (job #1527530) | info-arena 2.0 | Cod sursa (job #1897148) | Cod sursa (job #46339) | Cod sursa (job #1916703)
#include <bits/stdc++.h>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int nMax = 10000003;
const int mod = 1000000;
struct Hash{
vector <int> v[mod];
inline bool Search(const int x) {
int r = x % mod;
for(const auto & i : v[r]) {
if(i == x) {
return 1;
}
}
return 0;
}
inline void Insert(const int x) {
if(Search(x)) {
return;
}
int r = x % mod;
v[r].push_back(x);
}
inline void Del(const int x) {
int r = x % mod;
int dim = v[r].size();
for(int i = 0; i < dim; i++) {
if(v[r][i] == x) {
v[r][i] = v[r][dim - 1];
v[r].pop_back();
return;
}
}
}
};
Hash h;
int main()
{
int n, tip, x;
f >> n;
for(int i = 1; i <= n; i++) {
f >> tip >> x;
if(tip==1)
h.Insert(x);
else
if(tip==2)
h.Del(x);
else
g << h.Search(x) <<"\n";
}
return 0;
}