Skip to content

Instantly share code, notes, and snippets.

@sergiosvieira
Last active September 1, 2020 12:03
Show Gist options
  • Select an option

  • Save sergiosvieira/397176caa58bd6e7cda6179f74e506df to your computer and use it in GitHub Desktop.

Select an option

Save sergiosvieira/397176caa58bd6e7cda6179f74e506df to your computer and use it in GitHub Desktop.
Common Main.cpp
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <numeric>
#include <limits>
#include <queue>
#include <memory>
static const int Max = std::numeric_limits<int>::max();
static const int Min = std::numeric_limits<int>::min();
using std::cout, std::cin;
struct Node;
using NodePtr = std::shared_ptr<Node>;
struct Node {
size_t label;
};
using Vector = std::vector<NodePtr>;
using Map = std::unordered_map<size_t, NodePtr>;
using Cmp = std::function<bool(NodePtr, NodePtr)>;
using PQueue = std::priority_queue<NodePtr, Vector, Cmp>;
std::ostream& operator<<(std::ostream& os, const Vector& v) {
os << "[";
for (size_t i = 0; i < v.size(); ++i) {
os << v[i];
if (i < v.size() - 1) cout << ", ";
}
os << "]";
return os;
}
std::ostream& operator<<(std::ostream& os, const Map& m) {
os << "{";
int counter = 0;
for (auto [key, value]: m) {
os << key
<< "->"
<< value;
if (counter++ < m.size() - 1) os << ", ";
}
os << "}";
return os;
}
int main() {
PQueue pq([](NodePtr a, NodePtr b){
return a->label > b->label;
});
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment