2020杭电多校第七场1009(Increasing and Decreasing)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6852

Problem Description
Notice:Don't output extra spaces at the end of one line.
Given n,x,y, please construct a permutation of length n, satisfying that:
- The length of LIS(Longest Increasing Subsequence) is equal to x.
- The length of LDS(Longest Decreasing Subsequence) is equal to y .
If there are multiple possible permutations satisfying all the conditions, print the lexicographically minimum one.
 
Input
The first line contains an integer T(1T100), indicating the number of test cases.
Each test case contains one line, which contains three integers n,x,y(1n1e5,1x,yn).
 
Output
For each test case, the first line contains ``YES'' or ``NO'', indicating if the answer exists. If the answer exists, output another line which contains n integers, indicating the permutation.
 
Sample Input
4
10 1 10
10 10 1
10 5 5
10 8 8
 
Sample Output
YES
10 9 8 7 6 5 4 3 2 1
YES
1 2 3 4 5 6 7 8 9 10
YES
1 2 3 5 4 10 9 8 7 6
NO
 
题意:给出字典序最小的,长度为n的,最长上升子序列为x,最长下降子序列为y的序列
题解:n必须大于x*y+1并且n要小于x+y-1,之后将序列分成a块,设第i块长度为xi,则x1+x2+...+xa=n且xa=b,1<=xi<=b,并逐个枚举
 
posted @ 2020-08-11 20:57  麦客_zeng  阅读(276)  评论(0)    收藏  举报