Add solution for "Day 18: RAM Run", part 2
This commit is contained in:
@@ -33,8 +33,11 @@ class RamRun
|
||||
int maxBytes_;
|
||||
int nBytes_;
|
||||
Grid<int> vertexReferences_;
|
||||
WeightedEdgeGraph::PathsResult dijkstraResult_;
|
||||
static constexpr char getUnknownVertexReference();
|
||||
static constexpr char getNoVertexReference();
|
||||
void buildGraph(WeightedEdgeGraph& graph);
|
||||
bool tryMarkCorrupted(const std::string& line, int& corruptedVertex);
|
||||
WeightedEdgeGraph buildGraph();
|
||||
int getVertex(WeightedEdgeGraph& graph, const size_t x, const size_t y);
|
||||
void resetVertexReferences();
|
||||
};
|
||||
|
||||
@@ -28,7 +28,23 @@ class WeightedEdgeGraph
|
||||
void addEdge(const int vertex1, const int vertex2, const int weight);
|
||||
int getVertexWeight(const int vertex) const;
|
||||
int getEdgeWeight(const int edge) const;
|
||||
std::vector<int> dijkstra(const int source) const;
|
||||
|
||||
struct PathsResult
|
||||
{
|
||||
PathsResult()
|
||||
: distances{}, predecessors{}
|
||||
{
|
||||
}
|
||||
PathsResult(const size_t size, const int initialDistance, const int initialPredecessor)
|
||||
: distances(size, initialDistance), predecessors(size, initialPredecessor)
|
||||
{
|
||||
}
|
||||
std::vector<int> distances;
|
||||
std::vector<int> predecessors;
|
||||
};
|
||||
|
||||
PathsResult dijkstra(const int source) const;
|
||||
static constexpr int getInfiniteDistance();
|
||||
|
||||
struct Incidence
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user