[Python] Easy solution with comments
Since N is small, there is about 2^N cases because each person can be either good or bad.\n\nWe can search for all cases, and for each case we check if there is
Since `N` is small, there is about `2^N` cases because each person can be either good or bad.\n\nWe can search for all cases, and for each case we check if there is any contradictions.\n\nFor example, if person `A` is bad in current case, but some good guy states that `A` is good, it\'s obvious that this is a contradiction. The case for `A` being good is similar.\n\nTime complexity: `O((2^N) * (N^2))`\n\n```python\nclass Solution:\n    def maximumGood(self, mat):\n        n = len(mat)\n        \n        good_stated = [[] for _ in range(n)]\n        bad_stated = [[] for _ in range(n)]\n        \n        # store all person i who says that j is good (or bad)\n        for i in range(n):\n            for j in range(n):\n                if mat[i][j] == 0:\n                    bad_stated[j].append(i)\n                if mat[i][j] == 1:\n                    good_stated[j].append(i)\n        \n        ans = 0\n        \n        # start check every cases\n        mask = (1 << n) - 1\n        while mask:\n            cur = sum(1 for i in range(n) if (1 << i) & mask)\n            for i in range(n):\n                if (1 << i) & mask:\n                    # if person i is good but some other good guy says i is bad -> contradiction\n                    if any((1 << per) & mask for per in bad_stated[i]):\n                        break\n                else:\n                    # if person i is bad but some other good guy says i is good -> contradiction\n                    if any((1 << per) & mask for per in good_stated[i]):\n                        break\n            else:\n                # no contradiction, update answer\n                ans = max(ans, cur)\n            mask -= 1\n        return ans\n```
[]