#pragma once #include #include #include #include #include #include #include using namespace std; bool nextComb(vector &indices, int n) { int k = indices.size(); int i = n - 1; int j = k - 1; while (indices[j] == i) { if (j == 0) return 1; i--; j--; } indices[j]++; for (int l = 0; l <= k - j - 1; l++) { indices[j + l] = indices[j] + l; } return 0; } template unordered_set intersectSets(unordered_set s1, unordered_set s2) { unordered_set s; if (s1.size() <= s2.size()) { for (auto &el : s1) { if (s2.find(el) != s2.end()) { s.insert(el); } } } else { for (auto &el : s2) { if (s1.find(el) != s1.end()) { s.insert(el); } } } return s; } template vector getShuffleKeys(unordered_map map) { srand(time(NULL)); vector output; for (auto& pair : map) { output.push_back(pair.first); } random_shuffle(output.begin(), output.end()); return output; }