#956
Gold III
PASIJANS
시간 제한
6s
메모리 제한
128MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Goran Žužić, Luka Kalinovčić Pasijans, patience, or solitaire is the name for a group of single player card games. One new such game, so new it has no name, is played with cards sporting random integers as values. The game starts by shuffling all cards and distributing them in N sequences, not necessarily of equal length. During each turn, the player can remove the first card in any sequence and place it at the end of the “Solution sequence”. The card that was second in the selected sequence now becomes the first and the turn ends. Of course once the card is in the “Solution sequence” it cannot be removed, replaced or altered in any way. So don't even try. The game ends when all cards are in the “Solution sequence”. The object of the game is to construct the best possible “Solution sequence”. One sequence is better than the other if for the first cards they differ, lets call them X and Y, the value on the card X is smaller than the value on the card Y. Write a program that finds the best possible “Solution sequence”.

입력

The first line contains one integer N (1 ≤ N ≤ 1000), number of starting sequences. Next N lines contain description of input sequences. Each line starts with an integer L (1 ≤ L ≤ 1000), length of the sequence. It's followed by L integers, smaller than 100.000.000.

출력

One line containing ∑L numbers, the best possible “Solution sequence” obtainable. Author: Goran Žužić, Luka Kalinovčić

예제 입력 1

3
1 2
1 100
1 1

예제 출력 1

1 2 100

예제 입력 2

2
5 10 20 30 40 50
2 28 27

예제 출력 2

10 20 28 27 30 40 50

예제 입력 3

2
3 5 1 2
3 5 1 1

예제 출력 3

5 1 1 5 1 2
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Gold III1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.