Pagini recente » Cod sursa (job #1305615) | Cod sursa (job #1560382) | Cod sursa (job #1535132) | Diferente pentru problema/cuba intre reviziile 30 si 31 | Cod sursa (job #2975450)
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int HASH_VALUE = 999117;
vector<int> hashTable[HASH_VALUE];
int n, op, x;
int main() {
fin >> n;
for (int i = 1; i <= n; i++) {
fin >> op >> x;
int hash = x % HASH_VALUE;
auto xAddress = find(hashTable[hash].begin(), hashTable[hash].end(), x);
if (op == 1) {
if (xAddress == hashTable[hash].end())
hashTable[hash].push_back(x);
} else if (op == 2) {
if (xAddress != hashTable[hash].end())
hashTable[hash].erase(xAddress);
} else {
fout << (xAddress != hashTable[hash].end()) << '\n';
}
}
return 0;
}