#P7726. 天体探测仪(Astral Detector)

天体探测仪(Astral Detector)

Background

By exploring the ancient archives, you successfully built the Astral Detector. You need to use it to discover hidden astral technology.

Problem Description

To find the astral technology, you first need to obtain a string of astral codes—it is a permutation of 1n1 \sim n.

The Astral Detector can, for a given length ll, return the minimum value of an interval of length ll in the code.

Unfortunately, the minimum values of all intervals of length ll are mixed together. What you get is only nn multisets S1,,SnS_1, \ldots , S_n:

  • SiS_i denotes the multiset formed by the minimum values of all intervals of length ii.

You need to reconstruct one possible astral code from these SiS_i. It is guaranteed that at least one correct astral code exists.

Input Format

The first line contains an integer nn, representing the length of the astral code.

The next nn lines follow. The ii-th line contains ni+1n - i + 1 integers (there are ni+1n - i + 1 intervals of length ii), representing each element in the multiset SiS_i. Note that the order of the elements is arbitrary, and is not necessarily the left-to-right order of the intervals.

Output Format

Output one line with nn integers p1,p2,,pnp_1, p_2, \ldots , p_n, representing the astral code you reconstructed.

If there are multiple feasible solutions, you may output any one of them.

4
4 3 2 1
1 2 1
1 1
1

3 1 2 4

Hint

[Sample 1 Explanation]

The astral code in the sample output is: p=[3,1,2,4]p = [3, 1, 2, 4].

The multiset of minimum values of intervals of length 11: S1={3,1,2,4}={4,3,2,1}S_1 = \{ 3, 1, 2, 4 \} = \{ 4, 3, 2, 1 \}.

The multiset of minimum values of intervals of length 22: $S_2 = \{ \min(3, 1), \min(1, 2), \min(2, 4) \} = \{ 1, 1, 2 \} = \{ 1, 2, 1 \}$.

The multiset of minimum values of intervals of length 33: $S_3 = \{ \min(3, 1, 2), \min(1, 2, 4) \} = \{ 1, 1 \}$.

The multiset of minimum values of intervals of length 44: S4={min(3,1,2,4)}={1}S_4 = \{ \min(3, 1, 2, 4) \} = \{ 1 \}.

Each SiS_i corresponds to the input.

Other feasible answers are also accepted, such as p=[4,2,1,3]p = [4, 2, 1, 3].


[Constraints]

This problem uses bundled testdata.

For 100%100\% of the data: 2n8002 \le n \le 800.

Subtask ID Score nn \le Special Constraints
11 2626 66 None
22 2424 1616
33 1212 800800 For each i[1,n]i \in [1, n], there are no two equal elements in SiS_i
44 3838 None

Translated by ChatGPT 5