c++ solution
\nclass Solution {\npublic:\n    Solution(int n_rows, int n_cols) : n_rows(n_rows), n_cols(n_cols), size(n_rows * n_cols) {\n        srand(time(nullptr));\n    
```\nclass Solution {\npublic:\n    Solution(int n_rows, int n_cols) : n_rows(n_rows), n_cols(n_cols), size(n_rows * n_cols) {\n        srand(time(nullptr));\n    }\n    \n    vector<int> flip() {\n        int id = rand() % size;\n        int rid = id;\n       \n        --size;\n        \n        if (holes.count(id)) {\n           id = holes[id];\n        } \n        \n        // Create or update whole at real index rid. Since the\n        // virtual space is shrinking move the hole at it boundary\n        // to rid or point to boundary\n        holes[rid] = holes.count(size) ? holes[size] : size;\n        \n        return {id / n_cols, id % n_cols};\n        \n    }\n    \n    void reset() {\n        holes.clear();\n        size = n_rows * n_cols;\n    }\n    \nprivate:\n    int n_rows;\n    int n_cols;\n    int size;\n    unordered_map<int, int> holes;\n};\n\n/**\n * Your Solution object will be instantiated and called as such:\n * Solution obj = new Solution(n_rows, n_cols);\n * vector<int> param_1 = obj.flip();\n * obj.reset();\n */\n\t```
[]