func_code_string: #include <bits/stdc++.h>   using namespace std;   struct segment {     int l, r;   };   segment s[1010];   int n, ans[1010], m, pi[1010], d[1010];   bool operator<(const segment &a, const segment &b) { return a.r < b.r; }   int main() {     int i, j;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> s[i].l >> s[i].r;       if (s[i].l > s[i].r) swap(s[i].l, s[i].r);     }     sort(s + 1, s + n + 1);     s[0].r = s[0].l = -2147483647;     pi[0] = 0;     for (i = 1; i <= n; i++) {       j = i - 1;       while (pi[j] == m) {         if (s[j].r < s[i].l) {           d[i] = -1;           break;         }         j--;       }       if (d[i] == -1)         d[i] = d[i - 1] + 1, ans[++m] = s[i].r, pi[i] = m;       else         pi[i] = m, d[i] = d[i - 1];     }     printf( %d n , d[n]);     for (i = 1; i <= m; i++) printf( %d  , ans[i]);     return 0;   }   