Superposition of many rectilinear skylines

The skyline of a city shows the horizon view of its buildings. In this problem we are dealing with rectilinear skylines such us the ones shown in the figure. Each skyline can be represented by a vector of points [(x0,y0),,(xn1,yn1)][(x_0,y_0),\ldots,(x_{n-1},y_{n-1})] with the following properties: xi,yi0i{0,,n1}xi1<xii{1,,n1}yi1yii{1,,n1}x0>0,yn1=0\begin{eqnarray*} x_i, y_i \geq 0 & & \forall i\in\{0,\ldots,n-1\}\\ x_{i-1} < x_i & & \forall i\in\{1,\ldots,n-1\}\\ y_{i-1} \neq y{i} & & \forall i\in\{1,\ldots,n-1\}\\ x_0 > 0, & & y_{n-1} = 0 \end{eqnarray*} An empty skyline is represented by an empty vector. A non-empty skyline must have at least two points.

The next figure shows three skylines that are represented by the red points. The top-left skyline is represented by the vector of points: [(1,2),(4,4),(6,1),(8,0),(10,3),(12,1),(14,0)][(1,2), (4,4), (6,1), (8,0), (10,3), (12,1), (14,0)]

image

This problem consists of generating the skyline obtained by the superposition of a sequence of skylines. In the figure, the skyline at the right is obtained by the superposition of the two skylines at the left.

Input

Input will start with the number ss of skylines to process, with s2s\ge 2. Then, each skyline will be represented by its number of points nn and its set of points x0y0x1y1xn1yn1x_0~y_0~x_1~y_1~\ldots~x_{n-1}~y_{n-1} (fullfilling the previous properties). All the values are integers.

Output

The output will consist of a line, representing the skyline obtained after the superposition of the given skylines.

Observation

Download the code.cc file: you only have to implement the skyline() function and reuse the skyline_\_superposition() function from problem P76893.

Problem information

Author: Jordi Petit and Jordi Cortadella

Generation: 2026-01-25T11:27:26.033Z

© Jutge.org, 2006–2026.
https://jutge.org