Who so ever Tested this problem does not do his job properly
If the intended solution is O(2^n*N^2) then this is plain embarrasing \n\nAC Code after 12 attempts of pointless optimizations and seeing the rank fall from 200
If the intended solution is O(2^n*N^2) then this is plain embarrasing \n\nAC Code after 12 attempts of pointless optimizations and seeing the rank fall from 200 to 2000 :\n```\n#pragma GCC optimize("Ofast")\n#pragma GCC target("avx,avx2,fma")\ntypedef long long ll;\n#define is(S, i) ((S >> i) & 1)\n\nclass Solution {\npublic:\n    \n    int maximumGood(vector<vector<int>>& st) {\n        int n=st.size();\n        int lim= 1LL<<n;\n        lim--;\n        int ans=0;\n        unordered_map<int,int>has;\n        for(int mask=1;mask<=lim;mask++){\n            if(has[mask])continue;\n            int status[n];\n            queue<int>q;\n             int vis[n];\n            ll sz=0;\n            memset(vis,0,sizeof(vis));\n            memset(status,0,sizeof(status));\n            for(int j=0;j<n;j++){\n                if(is(mask,j)){\n                    status[j]=1;\n                    q.push(j);\n                    vis[j]=1;\n                }\n            }\n           \n            //vector<ll>g,b;\n            bool f=1;\n            \n            while(!q.empty()){\n                if(!f)break;\n                int i=q.front();\n                vis[i]=1;\n                q.pop();\n                    for(int j=0;j<n;j++){\n                        \n                        if(!f)break;\n                        if(st[i][j]==1){\n                            if(vis[j]==0){\n                                vis[j]=1;\n                                status[j]=1;\n                                q.push(j);\n                            }\n                            else{\n                                if(status[j]==0){\n                                    f=0;\n                                    break;\n                                }\n                            }\n                        }\n                        if(st[i][j]==0){\n                            \n                            if(vis[j]==0){\n                                vis[j]=1;\n                                status[j]=0;\n                            }\n                            else{\n                                if(status[j]==1){\n                                    f=0;\n                                    break;\n                                }\n                            }\n                            \n                        }\n                        //Check ends here\n                         \n                    }\n                \n            }\n            if(f){\n            int c=0;\n                int val=0;\n            for(int j=0;j<n;j++){\n                if(status[j]==1 ){\n                    c++;\n                    val+=1<<j;\n                }\n            }\n            if(f){\n                ans=max(ans,c);\n                has[val]=1;\n            }\n            }\n            \n        }\n        return ans;\n        \n    }\n};\n```\n\nTLE Code in hidden test cases at first attempt\n```\n#pragma GCC optimize("Ofast")\n#pragma GCC target("avx,avx2,fma")\ntypedef long long ll;\n#define is(S, i) ((S >> i) & 1)\n\nclass Solution {\npublic:\n    \n    int maximumGood(vector<vector<int>>& st) {\n        int n=st.size();\n        int lim= 1LL<<n;\n        lim--;\n        int ans=0;\n        unordered_map<int,int>has;\n        for(int mask=1;mask<=lim;mask++){\n            if(has[mask])continue;\n            vector<int>status(n);\n            queue<int>q;\n             vector<bool>vis(n);\n            ll sz=0;\n            for(int j=0;j<n;j++){\n                if(is(mask,j)){\n                    status[j]=1;\n                    q.push(j);\n                    vis[j]=1;\n                }\n            }\n           \n            //vector<ll>g,b;\n            bool f=1;\n            \n            while(!q.empty()){\n                if(!f)break;\n                int i=q.front();\n                vis[i]=1;\n                q.pop();\n                    for(int j=0;j<n;j++){\n                        \n                        if(!f)break;\n                        if(st[i][j]==1){\n                            if(vis[j]==0){\n                                vis[j]=1;\n                                status[j]=1;\n                                q.push(j);\n                            }\n                            else{\n                                if(status[j]==0){\n                                    f=0;\n                                    break;\n                                }\n                            }\n                        }\n                        if(st[i][j]==0){\n                            \n                            if(vis[j]==0){\n                                vis[j]=1;\n                                status[j]=0;\n                            }\n                            else{\n                                if(status[j]==1){\n                                    f=0;\n                                    break;\n                                }\n                            }\n                            \n                        }\n                        //Check ends here\n                         \n                    }\n                \n            }\n            if(f){\n            int c=0;\n                int val=0;\n            for(int j=0;j<n;j++){\n                if(status[j]){\n                    c++;\n                    val+=1<<j;\n                }\n            }\n            if(f){\n                ans=max(ans,c);\n                has[val]=1;\n            }\n            }\n            \n        }\n        return ans;\n        \n    }\n};\n```\nI am ranting here because both solutions have no difference and I had to suffer too much today without any fault of my own
[]