#P12453. [INOI Team Selection 2021] Lisdeque
[INOI Team Selection 2021] Lisdeque
题目描述
Master Oogway has deques, all elements in these deques are different.
Panda wants to be the Dragon Warrior, needs to make most powerful array he can with this deques.
In each turn he can choose a nonempty deque (if there is any) and choose it's front or back and append that value to end of the array, then pop that value from the deque. help him to find most powerful array he can make.
The power of an array is the longest increasing subsequence (LIS) of it.
输入格式
First line of input contains integer , the number of deques Master Oogway has.
In the -th line of next line, there is an integer , the size of -th deque, followed by integers, elements of -th deque.
输出格式
In the first line of output, print the maximum LIS you can make, then print the resulted array, if there is more than one possible answer, you can print any of them.
3
4 7 2 3 5
3 1 11 9
4 10 4 8 6
9
1 7 2 3 10 4 5 6 8 9 11
提示
constraints
Subtasks
subtask | score | limits |
---|---|---|
1 | 50 | |
2 | No extra limits |