CF1978C Manhattan Permutations
题目描述
设排列 $p$ 的曼哈顿值为 $ |p_1 - 1| + |p_2 - 2| + \ldots + |p_n - n| $ 。
例如,对于排列 $ [1, 2, 3] $ , 它的曼哈顿值为 $ |1 - 1| + |2 - 2| + |3 - 3| = 0 $ ;
对于排列 $ [3, 1, 2] $ , 它的曼哈顿值为 $ |3 - 1| + |1 - 2| + |2 - 3| = 2 + 1 + 1 = 4 $ 。
给出 $ n $ 和 $ k $ . 询问是否存在一个长度为 $ n $ 的排列 $ p $ 的曼哈顿值为 $ k $ ,若存在,输出排列 $ p $ 。
输入格式
每个测试点包含多组数据。
第一行包括一个整数 $ t $ ( $ 1 \leq t \leq 10^{4} $ ),表示测试数据的组数。
接下来 $ t $ 行,每行包括两个整数 $ n $ 和 $ k $ ( $ 1 \le n \le 2 \cdot 10^{5}, 0 \le k \le 10^{12} $ ) ,分别表示你需要找到的排列的长度与曼哈顿值。
保证所有数据中的 $ n $ 的和不会超过 $ 2 \cdot 10^{5} $ 。
输出格式
对于每组数据,如果不存在合法的排列,输出"No";否则先输出一行"Yes",然后在第二行输出 $ n $ 个不同的整数 $ p_1, p_2, \ldots, p_n $ ( $ 1 \le p_i \le n $ ) 表示一个合法的排列。
如果存在多个合法的排列,你可以输出任意一个。
"Yes"和"No"大小写不敏感(例如,"yEs", "yes", "Yes", "YES" 都会被视为正确的答案)。
说明/提示
In the first test case, the permutation $ [3, 1, 2] $ is suitable, its Manhattan value is $ |3 - 1| + |1 - 2| + |2 - 3| = 2 + 1 + 1 = 4 $ .
In the second test case, it can be proven that there is no permutation of length $ 4 $ with a Manhattan value of $ 5 $ .
In the third test case, the permutation $ [1,2,3,4,5,6,7] $ is suitable, its Manhattan value is $ |1-1|+|2-2|+|3-3|+|4-4|+|5-5|+|6-6|+|7-7|=0 $ .