C++ solution with detailed explanation
Explanation:\n1. traverse every single number in colsum and assign initial values to the cells\n2. Before applying swaps on upper cell and its corresponding low
Explanation:\n1. traverse every single number in colsum and assign initial values to the cells\n2. Before applying swaps on upper cell and its corresponding lower cell, we check if the answer can be achieved.\n3. Apply swaps\n4. done\n\n```\nvector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        int n = colsum.size();\n        int count_two;\n        vector<vector<int>> mat(2, vector<int>(n, 0));\n        \n\t\t//traverse colsum\n        for (int i = 0; i < colsum.size(); i++){\n\t\t\t////if 2, then both upper and lower cell is 1 for sure\n            if (colsum[i] == 2){\n                mat[0][i] = 1;\n                mat[1][i] = 1;\n                count_two++;\n            } \n\t\t\t//we give upper cell value of 1 if colsum[i] is 1\n\t\t\t//lower cell value is 0\n\t\t\telse if (colsum[i] == 1){\n                mat[0][i] = 1;\n                mat[1][i] = 0;\n            }\n        }\n        \n        //now we calculate the value of the upper and lower cell\n        int count_upper = 0;\n        int count_lower = 0;\n        \n        for (int i = 0; i < colsum.size(); i++){\n            count_upper += mat[0][i];\n            count_lower += mat[1][i];\n        }\n        \n\t\t//since all the 1s are assigned to the upper cells, \n\t\t//if count_upper is still smaller than upper, \n\t\t//there is no possible moves we can apply to make count_upper larger\n\t\t//hence output empty array\n        if (count_upper < upper){\n            return {};\n        }\n\t\t\n        bool flag = true;\n        int diff = abs(count_upper - upper);\n        \n        //now we need to compare four values below:\n\t\t//count_upper, upper, count_lower, lower\n\t\t//there must be an even number of even and odd numbers for the four values above\n        int odd_count = 0;\n        int even_count = 0;\n        \n        if (count_upper % 2 == 1){\n            odd_count++;\n        } else {\n            even_count++;\n        }\n        if (count_lower % 2 == 1){\n            odd_count++;\n        } else {\n            even_count++;\n        }\n        if (upper % 2 == 1){\n            odd_count++;\n        } else {\n            even_count++;\n        }\n        if (lower % 2 == 1){\n            odd_count++;\n        } else {\n            even_count++;\n        }\n        //if does not pass the check.. return empty string\n        if( odd_count % 2 == 1 || even_count  % 2== 1 || count_upper + count_lower != upper + lower){\n            return {};\n        }\n        \n        if (diff == 0){\n            return mat;\n        }\n        \n        if (diff > 0){\n            flag = true;\n        } else {\n            flag = false;\n        }\n        \n        \n        for (int i = 0; i < colsum.size() && diff > 0; i++){\n            if (mat[0][i] == 1 && mat[1][i] == 0 && flag == true){\n                swap(mat[0][i], mat[1][i]);\n                diff--;\n            }\n            \n            if (mat[0][i] == 0 && mat[1][i] == 1 && flag == false){\n                swap(mat[0][i], mat[1][i]);\n                diff--;\n            }\n        }\n        \n        return mat;\n    }
[]