思路:
- 题意: 让构造一个长度为n的序列,使得其最长递增子序列长度为x,最长递减子序列的长度为y。若无法构成自己输出 “NO”。
- 官方题解:
- cls代码思路:
将整个序列分成x块,每一块找一个元素出来形成的就是最长递增子序列;而递减序列正好是某一整块元素。
代码实现:
#include<bits/stdc++.h>
#define endl '\n'
#define null NULL
#define ll long long
#define int long long
#define pii pair<int, int>
#define lowbit(x) (x &(-x))
#define ls(x) x<<1
#define rs(x) (x<<1+1)
#define me(ar) memset(ar, 0, sizeof ar)
#define mem(ar,num) memset(ar, num, sizeof ar)
#define rp(i, n) for(int i = 0, i < n; i ++)
#define rep(i, a, n) for(int i = a; i <= n; i ++)
#define pre(i, n, a) for(int i = n; i >= a; i --)
#define IOS ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int way[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
using namespace std;
const int inf = 0x7fffffff;
const double PI = acos(-1.0);
const double eps = 1e-6;
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;
int t, n, x, y;
vector<int> vt;
signed main()
{
IOS;
cin >> t;
while(t --){
cin >> n >> x >> y;
int a = sqrt(n), b = n/a;
if(a*b != n) b ++;
if(x+y > n+1 || x+y < a+b) cout << "NO" << endl;
else{
cout << "YES" << endl;
vt.clear();
for(int i = x; i; i --){
int xx = min(n-i+1, y);
for(int j = n-xx+1; j <= n; j ++) vt.push_back(j);
n -= xx;
}
for(int i = vt.size()-1; ~i; i --) cout << vt[i] << " \n"[!i];
}
}
return 0;
}