← Home
write a go solution for D. Inversion Value of a Permutationtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA permutation of length n is an array of n integers, where each number from 1 to n appears exactly once. An inversion in a permutation p is a pair of indices (i,j) such that i<j and p_i>p_j.For a permutation p, we define its inversion value as the number of its subsegments that contain at least one inversion. Formally, this is the number of pairs of integers (l,r) (1<=l<r<=n) for which there exists a pair of indices (i,j) satisfying the following conditions: l<=i<j<=r and p_i>p_j.For example, for the permutation [3,1,4,2], the inversion value is 5.You are given two integers n and k. Your task is to construct a permutation of length n with an inversion value equal to exactly k.InputThe first line contains one integer t (1<=t<=500) — the number of test cases.Each test case consists of a single line containing two integers n and k (2<=n<=30; 0<=k<=dfracn(n-1)2).OutputFor each test case, output the answer as follows:  if the desired permutation does not exist, output a single integer 0;  otherwise, output n distinct integers from 1 to n — the desired permutation. If there are multiple such permutations, you may output any of them. ExampleInput54 55 105 06 83 1Output3 1 4 2
5 4 3 2 1
1 2 3 4 5
2 3 5 6 1 4
0. Output only the code with no comments, explanation, or additional text.