5
vector<vector<int>> reconstructQueue(vector<vector<int>> &people) {7
BIT = vector<int>(n + 1, 0); // BIT[i+1] recorded the res[i] information8
// because BIT[0] is not used.9
for (int i = 2; i <= n; i++)10
update(i, 1); // BIT[1] is the 0th empty position, so we didn't add 111
sort(people.begin(), people.end(), cmp);12
vector<vector<int>> res(n, vector<int>());13
for (int i = 0; i < n; i++) {16
int mid = l + (r - l) / 2;17
if (getsum(mid + 1) < people[i][1])18
l = mid + 1; // we need get the index mid empty information, but19
// actually it's stored in BIT[mid+1]28
void update(int x, int v) {29
for (int i = x; i <= n; i += (i & -i)) {35
for (int i = x; i > 0; i -= (i & -i)) {40
static bool cmp(vector<int> &p1, vector<int> &p2) {