Under construction

Still being built. Things may change

Network Vulnerability

Time limit3sMemory limit512 MB

Summary
Given an interval representation of an interval graph, compute for each k the maximum number of connected components left after deleting exactly k vertices.
Level

Hard8 of 10

Topics
Dynamic programming, Intervals, Graph
Solved
No attempts yet

Problem

Network vulnerability describes how much network performance drops under disruptions such as natural disasters, element failures, or adversarial attacks. A network is often modeled as a graph, where vertices correspond to nodes and edges to links, so the two terms network and graph are used interchangeably. The connectivity is the minimum number of vertices whose deletion leaves a disconnected graph or a one-vertex graph. It is the most important measure of network vulnerability.

Connectivity captures only part of a graph's resistance to vertex deletion. Many other metrics have been proposed, and the toughness and the scattering number are the most popular. Both rest on the maximum number of connected components left after removing k vertices. Let ck(G)c_k(G) denote the maximum number of connected components obtained by removing exactly kk vertices from a graph GG. Given a graph GG and a positive integer kk, computing ck(G)c_k(G) is computationally intractable.

For some graph classes, such as interval graphs, ck(G)c_k(G) can be computed in polynomial time. An interval graph is the intersection graph of a family of (closed) intervals on the real line. Two vertices are joined by an edge if and only if their intervals intersect. The family is called an interval representation of the graph. The figure shows an interval graph and its interval representation.

(a) an interval graph(b) an interval representation of the graph of (a)

Given an interval representation of an interval graph GG with nn vertices, write an efficient program that computes ck(G)c_k(G) for all k∈{0,1,…,n−1}k \in \{0, 1, \ldots, n-1\}. For the representation in figure (b), c0(G),c1(G),…,c7(G)c_0(G), c_1(G), \ldots, c_7(G) are 1, 1, 1, 2, 2, 3, 2, 1, respectively.

Input

The first line contains a positive integer nn, the number of intervals, where n≤2,000n \le 2{,}000. Each of the next nn lines contains the left and right endpoints of one interval. All endpoints are integers between −100,000,000-100{,}000{,}000 and 100,000,000100{,}000{,}000, inclusive.

Output

Print one line with nn numbers c0(G),c1(G),…,cn−1(G)c_0(G), c_1(G), \ldots, c_{n-1}(G), separated by single spaces.

Examples4

  1. Example 1

    Input
    8
    3 8
    1 8
    1 7
    1 6
    4 8
    1 2
    3 5
    7 8
    
    Expected output
    1 1 1 2 2 3 2 1
    
  2. Example 2

    Input
    3
    -2 -2
    -2 7
    -2 7
    
    Expected output
    1 1 1
    
  3. Example 3

    Input
    4
    -1 -1
    3 4
    5 6
    7 8
    
    Expected output
    4 3 2 1
    
  4. Example 4

    Input
    5
    1 2
    2 3
    3 4
    6 7
    7 8
    
    Expected output
    2 3 3 2 1