C++  generate all possible scenarios
```\nclass Solution {\npublic:\n    int maximumGood(vector>& grid) {\n        int n = grid.size();\n        int numSubSets = 1<<n;\n        int ans = 0;\n      
```\nclass Solution {\npublic:\n    int maximumGood(vector<vector<int>>& grid) {\n        int n = grid.size();\n        int numSubSets = 1<<n;\n        int ans = 0;\n        for(int bitmask=1; bitmask<numSubSets; bitmask++)\n        {\n            vector<int> good(n,0),bad(n,0);\n            int count = 0;\n            for(int i=0; i<n; i++)\n            {\n                if((bitmask&(1<<i))!=0)\n                {\n                    count++;\n                    good[i] = 1;\n                    bad[i] = 0;\n                }\n                else\n                {\n                    good[i] = 0;\n                    bad[i] = 1;\n                }\n                if(good[i]==1 && bad[i]==1) break;\n            }\n            bool flag = true;\n            for(int i=0; i<n; i++)\n            {\n                for(int j=0; j<n; j++)\n                {\n                    if(i==j) continue;\n                    if(good[i]==1)\n                    {\n                        if(grid[i][j]==0 && bad[j]==0)\n                        {\n                            flag = false;\n                            break;\n                        }\n                        if(grid[i][j]==1 && good[j]==0)\n                        {\n                            flag = false;\n                            break;\n                        }\n                    }\n                }\n            }\n            if(flag==true)\n                ans = max(ans,count);\n        }\n        return ans;\n    }\n};
['C']