C++ code
\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        int sum=0, twos=0;\n        for(int
```\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        int sum=0, twos=0;\n        for(int i = 0; i < colsum.size(); ++i){\n            sum += colsum[i];\n            if(colsum[i] == 2) ++twos;\n        }\n        if(upper + lower != sum || upper < twos || lower < twos) \n            return {};\n        \n        vector<int> upper_row(colsum.size(), 0);\n        for(int i = 0; i < colsum.size() && upper > 0; ++i){\n            if(colsum[i] == 2 || colsum[i] == 1){\n                upper_row[i] = 1;\n                colsum[i]-= upper_row[i];\n                upper--;\n            }\n        }\n        \n        return {upper_row, colsum};\n    }\n};\n```
[]