func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   int d[262144][4];   map<int, int> comp;   int r[262144], R, pr[262144];   vector<int> vec;   bool cmp(int a, int b) { return d[a][1] > d[b][1]; }   struct BIT {     int m[262144 * 2];     vector<int> v[262144];     void init() {       int i;       for (i = 0; i < n; i++) v[comp[d[i][0]]].push_back(i);       for (i = 0; i < 262144; i++) {         if (v[i].size()) {           sort(v[i].begin(), v[i].end(), cmp);           m[262144 + i] = d[v[i].back()][1];         } else           m[262144 + i] = 2147483647;       }       for (i = 262144 - 1; i >= 1; i--)         m[i] = m[i * 2] < m[i * 2 + 1] ? m[i * 2] : m[i * 2 + 1];     }     void gohelp(int p, int i) {       if (m[p] > d[i][3]) return;       if (p < 262144) {         gohelp(p * 2, i);         gohelp(p * 2 + 1, i);       } else {         while (v[p - 262144].size()) {           int j = v[p - 262144].back();           if (d[j][1] <= d[i][3]) {             vec.push_back(j);             r[j] = R;             pr[j] = i;             v[p - 262144].pop_back();           } else             break;         }         if (v[p - 262144].size())           m[p] = d[v[p - 262144].back()][1];         else           m[p] = 2147483647;         for (p /= 2; p; p /= 2)           m[p] = m[p * 2] < m[p * 2 + 1] ? m[p * 2] : m[p * 2 + 1];       }     }     void go(int p, int i) {       p += 262144;       gohelp(p, i);       for (; p > 1; p /= 2) {         if (p & 1) gohelp(p - 1, i);       }     }   } bit;   int main() {     int i;     scanf( %d , &n);     comp[0] = 1;     for (i = 0; i < n; i++) {       scanf( %d%d%d%d , &d[i][0], &d[i][1], &d[i][2], &d[i][3]);       comp[d[i][0]] = comp[d[i][2]] = 1;     }     i = 0;     for (auto& it : comp) it.second = i++;     bit.init();     memset(r, -1, sizeof(r));     vector<int> vecpr;     vecpr.push_back(n);     while (vecpr.size()) {       vec.clear();       R++;       for (int i : vecpr) bit.go(comp[d[i][2]], i);       vecpr = vec;     }     printf( %d n , r[n - 1]);     if (r[n - 1] != -1) {       vector<int> path;       for (i = n - 1; r[i] > 1; i = pr[i]) path.push_back(i);       path.push_back(i);       for (i = path.size() - 1; i >= 0; i--) printf( %d  , path[i] + 1);     }     return 0;   }   