Hungarian Algorithm
Intuition\nThe problem of selecting unique values from a 2D matrix such that no two selected cells are in the same row can be modeled as an assignment problem. 
### Intuition\nThe problem of selecting unique values from a 2D matrix such that no two selected cells are in the same row can be modeled as an [assignment problem](https://en.wikipedia.org/wiki/Assignment_problem). This is a classical optimization problem that can be effectively solved using graph theory. Specifically, the problem can be framed as finding a maximum-weight matching in a bipartite graph, which is equivalent to minimizing a cost function in the assignment problem.\n\n### Approach\nTo tackle this problem, we will:\n1. Construct a cost matrix where each entry represents the negative of the value to be maximized. This transformation allows us to use algorithms designed to minimize costs.\n2. Set up the cost matrix such that:\n   - If a value `j` is present in row `i`, its cost is `-j` (since we aim to maximize `j`, we use its negative as the cost to be minimized).\n   - If a value `j` is not present in row `i`, its cost is set to infinity (to signify that this value cannot be selected for this row).\n3. Incorporate dummy values with zero cost to handle cases where some rows might not have any eligible values, allowing the solution to include rows without selected values if necessary.\n4. Use the [Hungarian Algorithm](https://en.wikipedia.org/wiki/Hungarian_algorithm), implemented through `scipy.optimize.linear_sum_assignment`, to find the optimal assignment that minimizes the total cost.\n\n### Complexity\n- **Time Complexity**: O(n^3)\n- **Space Complexity**: O(n^2)\n### Code\n\n```python\nfrom scipy.optimize import linear_sum_assignment\n\nclass Solution:\n    def maxScore(self, grid: List[List[int]]) -> int:\n        # Convert each row of the grid into a set for efficient membership checking\n        grid_set = list(map(set, grid))\n        \n        m, n = len(grid), len(grid[0])\n        \n        # Initialize cost matrix with large values (representing infinity)\n        cost_matrix = [111 * [0] for _ in range(m)]  # 101, ..., 110 are dummy values\n        \n        for i in range(m):\n            for j in range(111):\n                if j > 100:\n                    continue  # Skip dummy values > 100\n                if j in grid_set[i]:\n                    cost_matrix[i][j] = -j  # Cost is negative of the value to maximize\n                else:\n                    cost_matrix[i][j] = float(\'inf\')  # Cannot assign this value to the row\n        \n        # Solve the assignment problem using the Hungarian Algorithm\n        row_ind, col_ind = linear_sum_assignment(cost_matrix)\n        \n        # Return the maximum score by summing up the values corresponding to the selected cells\n        return -sum(cost_matrix[i][j] for i, j in zip(row_ind, col_ind))\n```
['Python3']