From 9ecea0012b98f42debd536dc863b4ef2501eb859 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 15 Dec 2024 09:14:09 +0100 Subject: fixed old code for non-square maps --- 2024/12/day12a.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to '2024/12/day12a.cpp') diff --git a/2024/12/day12a.cpp b/2024/12/day12a.cpp index b972fd2..89cc3d9 100644 --- a/2024/12/day12a.cpp +++ b/2024/12/day12a.cpp @@ -46,8 +46,8 @@ public: cells = new char[M * N]; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { - region[N*i + j] = -1; - cells[N*i + j] = j < (int)lines[i].size() ? + region[M*i + j] = -1; + cells[M*i + j] = j < (int)lines[i].size() ? lines[i][j] : out_of_bound; } } @@ -74,7 +74,7 @@ private: int coord(pair p) { auto [i, j] = p; - return i >= N || i < 0 || j >= M || j < 0 ? -1 : N*i + j; + return i >= N || i < 0 || j >= M || j < 0 ? -1 : M*i + j; } }; -- cgit v1.3