#include <vector>
#include <assert.h>
#include <algorithm>
#include <unordered_map>
#include <iostream>
class Node {
public:
int a, b, c;
Node(std::vector<int> v) {
assert(v.size() > 2);
std::sort(begin(v), end(v));
a = v[0]; b = v[1]; c = v[2];
}
};
int main() {
auto hash = [](const Node& n){
size_t res = 17;
res = res * 31 + std::hash<int>()(n.a);
res = res * 31 + std::hash<int>()(n.b);
res = res * 31 + std::hash<int>()(n.c);
return res;
};
auto equal = [](const Node& n1, const Node& n2){
return n1.a == n2.a && n1.b == n2.b && n1.c == n2.c;
};
std::unordered_map<Node, int, decltype(hash), decltype(equal)> m(8, hash, equal);
std::vector<int> v {3, 8, 9};
Node n(v);
m[n] = 0;
for (auto const &nd : m)
std::cout << nd.first.a << ", " << nd.first.b << ", " << nd.first.c << ", " << nd.second << std::endl;
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFzc2VydC5oPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8dW5vcmRlcmVkX21hcD4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgTm9kZSB7CnB1YmxpYzoKICAgIGludCBhLCBiLCBjOwogICAgTm9kZShzdGQ6OnZlY3RvcjxpbnQ+IHYpIHsKICAgICAgICBhc3NlcnQodi5zaXplKCkgPiAyKTsKICAgICAgICBzdGQ6OnNvcnQoYmVnaW4odiksIGVuZCh2KSk7CiAgICAgICAgYSA9IHZbMF07IGIgPSB2WzFdOyBjID0gdlsyXTsKICAgIH0KfTsKCmludCBtYWluKCkgewogICAgYXV0byBoYXNoID0gW10oY29uc3QgTm9kZSYgbil7CiAgICAgICAgc2l6ZV90IHJlcyA9IDE3OwogICAgICAgIHJlcyA9IHJlcyAqIDMxICsgc3RkOjpoYXNoPGludD4oKShuLmEpOwogICAgICAgIHJlcyA9IHJlcyAqIDMxICsgc3RkOjpoYXNoPGludD4oKShuLmIpOwogICAgICAgIHJlcyA9IHJlcyAqIDMxICsgc3RkOjpoYX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