C++ || Bitmask || With Comments || Power Set
\nclass Solution {\nprivate:\n    bool isCorrect_Configuration(int c, vector<vector<int>>& arr, int n){\n        for(int i=0; i<n; i++){\n            if(c & (1<
```\nclass Solution {\nprivate:\n    bool isCorrect_Configuration(int c, vector<vector<int>>& arr, int n){\n        for(int i=0; i<n; i++){\n            if(c & (1<<i)){ //if ith person is a good person then only check his row\n                for(int j=0; j<n; j++){\n                    if(arr[i][j] != 2 && arr[i][j] != bool(c & (1<<j))){\n                        return false; //if at any moment, the given configuration fails to distinguish between good person or bad person according to given statements(arr), just return false, coz this an invalid configuration.\n                    }\n                }\n            }\n        }\n        return true;\n    }\n    \npublic:\n    int maximumGood(vector<vector<int>>& arr) {\n        int n = arr.size();\n        \n        //Power set \n        int maxi = 0;\n        for(int c=0; c<(1<<n); c++){ //generate all configurations\n            if(isCorrect_Configuration(c,arr,n)){ //if its a valid config, count the number of good persons in the mask\n                maxi = max(maxi,__builtin_popcount(c)); //and return the maximum of them\n            }\n        }\n        return maxi;\n        \n        //TC = O(N^2 * 2^N)\n        //SC = O(1)\n    }\n};\n```
['C', 'Bitmask']