func_code_string: #include <bits/stdc++.h>   using namespace std;   int mx[4005], need[4005];   int n, l[4005], r[4005], a[4005];   bool inter(int i, int j) {     if (l[i] >= l[j] && l[i] <= r[j]) return 1;     if (r[i] >= l[j] && r[i] <= r[j]) return 1;     if (l[j] >= l[i] && l[j] <= r[i]) return 1;     if (r[j] >= r[i] && r[j] <= r[i]) return 1;     return 0;   }   bool check(int d) {     int i, j, p, s;     r[0] = (1 << 30);     for (i = 1; i <= n; i++) need[i] = 0, mx[i] = n;     need[n] = n;     for (i = 1; i <= n; i++) {       for (j = i, s = 0; j <= n; j++)         if ((s += need[j]) > j - i + 1) return false;       for (j = i, s = 0; j <= n; j++)         if ((s += need[j]) == j - i + 1) break;       s = j;       for (j = 1, p = 0; j <= n; j++)         if (mx[j] > 0 && mx[j] <= s && r[j] < r[p]) p = j;       need[mx[p]]--, mx[p] = -1;       for (j = 1; j <= n; j++)         if (inter(p, j) && i + d < mx[j]) {           need[i + d]++, need[mx[j]]--;           mx[j] = i + d;         }       a[i] = p;     }     return 1;   }   int main() {     int i, ll, rr, mid;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d %d , &l[i], &r[i]);     ll = 0, rr = n - 1;     while (rr - ll > 1) {       mid = (ll + rr) >> 1;       if (check(mid))         rr = mid;       else         ll = mid;     }     check(rr);     for (i = 1; i <= n; i++) printf( %d  , a[i]);     return 0;   }   