diff --git a/Graphs 1/Largest_Piece.cpp b/Graphs 1/Largest_Piece.cpp index 2fa4a98..45507b3 100644 --- a/Graphs 1/Largest_Piece.cpp +++ b/Graphs 1/Largest_Piece.cpp @@ -71,7 +71,7 @@ int solve(int n, char cake[NMAX][NMAX]) { for (int j = 0; j < n; j++) { - if (arr[i][j] == 1) + if (arr[i][j] == 1 && visited[i][j]==0) { visited[i][j] = true; int current_maximum = count_ones(arr, n, i, j, visited); @@ -79,15 +79,8 @@ int solve(int n, char cake[NMAX][NMAX]) { maximum = current_maximum; } - for (int p = 0; p < n; p++) - { - for (int q = 0; q < n; q++) - { - visited[p][q] = false; - } - } } } } return maximum; -} \ No newline at end of file +}