C++ single rand() call
Revised from Random Pick with weight, use area as weight\n\nclass Solution {\n    random_device rd;\n    vector<int> areas;\n    vector<vector<int>> rects;\npub
Revised from [Random Pick with weight](https://leetcode.com/problems/random-pick-with-weight), use area as weight\n```\nclass Solution {\n    random_device rd;\n    vector<int> areas;\n    vector<vector<int>> rects;\npublic:\n    Solution(vector<vector<int>> input_rects) {\n        int total = 0;\n        rects = move(input_rects);\n        for (auto& rect : rects)\n            areas.push_back(total += (rect[2]-rect[0] + 1)*(rect[3]-rect[1] + 1));\n    }\n    \n    vector<int> pick() {\n        int p = rd() % areas.back(); // -1 for picking left-bottom point\n        int i = lower_bound(areas.begin(), areas.end(), p + 1) - areas.begin();\n        if (i > 0) p -= areas[i-1]; // get area of picked rectangle\n        int x = rects[i][2]-rects[i][0] + 1;\n        return {rects[i][0] + p%x, rects[i][1] + p/x};\n    }\n};\n```\n
[]