diff --git a/src/HoofIt.cpp b/src/HoofIt.cpp index 2bde820..634894b 100644 --- a/src/HoofIt.cpp +++ b/src/HoofIt.cpp @@ -19,6 +19,7 @@ #include #include +#include #include const std::string HoofIt::getPuzzleName() const @@ -34,23 +35,14 @@ const std::string HoofIt::getInputFileName() const void HoofIt::finish() { std::queue queue{}; - std::vector>> trailEndsMap{}; - trailEndsMap.reserve(lines.size()); - std::vector> trailScoreMap{}; - trailScoreMap.reserve(lines.size()); + Grid> trailEndsMap{ lines.size(), lines[0].size() }; + Grid trailScoreMap{ lines.size(), lines[0].size() }; for (int j = 0; j < lines.size(); j++) { - std::vector> endsRow{}; - endsRow.reserve(lines[j].size()); - trailEndsMap.push_back(endsRow); - std::vector scoreRow(lines[j].size(), 0); - trailScoreMap.push_back(scoreRow); - for (int i = 0; i < lines[j].size(); i++) { - std::vector ends{}; - trailEndsMap[j].push_back(ends); + trailScoreMap[j][i] = 0; if (lines[j][i] == getTrailTopChar()) { Point2 trailEnd{ i, j }; @@ -76,15 +68,15 @@ void HoofIt::finish() { queue.push(p); } - addUnique(trailEndsMap[trail.y][trail.x], trailEndsMap[p.y][p.x]); - trailScoreMap[p.y][p.x] += trailScoreMap[trail.y][trail.x]; + addUnique(trailEndsMap.cell(trail), trailEndsMap.cell(p)); + trailScoreMap.cell(p) += trailScoreMap.cell(trail); } } } else { - part1 += trailEndsMap[trail.y][trail.x].size(); - part2 += trailScoreMap[trail.y][trail.x]; + part1 += trailEndsMap.cell(trail).size(); + part2 += trailScoreMap.cell(trail); } } }