当前位置: 首页 > news >正文

C. Gorilla and Permutation

time limit per test

2 seconds

memory limit per test

256 megabytes

Gorilla and Noobish_Monk found three numbers nn, mm, and kk (m<km<k). They decided to construct a permutation†† of length nn.

For the permutation, Noobish_Monk came up with the following function: g(i)g(i) is the sum of all the numbers in the permutation on a prefix of length ii that are not greater than mm. Similarly, Gorilla came up with the function ff, where f(i)f(i) is the sum of all the numbers in the permutation on a prefix of length ii that are not less than kk. A prefix of length ii is a subarray consisting of the first ii elements of the original array.

For example, if n=5n=5, m=2m=2, k=5k=5, and the permutation is [5,3,4,1,2][5,3,4,1,2], then:

  • f(1)=5f(1)=5, because 5≥55≥5; g(1)=0g(1)=0, because 5>25>2;
  • f(2)=5f(2)=5, because 3<53<5; g(2)=0g(2)=0, because 3>23>2;
  • f(3)=5f(3)=5, because 4<54<5; g(3)=0g(3)=0, because 4>24>2;
  • f(4)=5f(4)=5, because 1<51<5; g(4)=1g(4)=1, because 1≤21≤2;
  • f(5)=5f(5)=5, because 2<52<5; g(5)=1+2=3g(5)=1+2=3, because 2≤22≤2.

Help them find a permutation for which the value of (∑ni=1f(i)−∑ni=1g(i))(∑i=1nf(i)−∑i=1ng(i)) is maximized.

††A permutation of length nn is an array consisting of nn distinct integers from 11 to nn in any order. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2] is not a permutation (as 22 appears twice in the array) and [1,3,4][1,3,4] is also not a permutation (as n=3n=3, but 44 appears in the array).

Input

The first line contains a single integer tt (1≤t≤1041≤t≤104)  — the number of test cases.

The only line of each case contains three integers nn, mm, kk (2≤n≤1052≤n≤105; 1≤m<k≤n1≤m<k≤n) — the size of the permutation to be constructed and two integers.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052⋅105.

Output

For each test case, output the permutation  — a set of numbers that satisfies the conditions of the problem. If there are multiple solutions, output any of them.

Example

Input

Copy

 

3

5 2 5

3 1 3

10 3 8

Output

Copy

5 3 4 1 2
3 2 1
10 9 8 4 7 5 6 1 2 3

Note

In the first example, (∑ni=1f(i)−∑ni=1g(i))=5⋅5−(0⋅3+1+3)=25−4=21

解题说明:此题是一道模拟题,为了保证结果尽可能大,可以采用贪心算法,将大于等于k的元素按降序放在排列最前面,将小于等于m的元素按升序放在排列最后面

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
ll n, m, k, a[N];int main()
{int tt;cin >> tt;while (tt--){cin >> n >> m >> k;ll x = n, y = 1;for (int i = 1; i <= n - m; i++){a[i] = x--;}for (int i = n - m + 1; i <= n; i++){a[i] = y++;}for (int i = 1; i <= n; i++){cout << a[i] << ' ';}cout << endl;}return 0;
}


http://www.mrgr.cn/news/63677.html

相关文章:

  • 计算机网路数据链路层详解
  • 问题记录02
  • 鸿蒙打包hvigorw clean报错No npmrc file is matched in the current user folder解决
  • Android开发教程viewpager2点击指示标也能切换
  • c# checked 和 unchecked 关键字
  • Python基于TensorFlow实现双向循环神经网络GRU加注意力机制分类模型(BiGRU-Attention分类算法)项目实战
  • 打响反对人工智能的第一枪
  • 多处理机调度(李昂学长视频总结)25新增考点
  • 音视频入门基础:FLV专题(22)——FFmpeg源码中,获取FLV文件音频信息的实现(中)
  • 奇瑞不客气智驾 晚不晚?
  • 浅谈DDD(领域驱动设计)
  • 齐次线性微分方程的解的性质与结构
  • 云计算的优势及未来发展趋势
  • 【Leecode】Leecode刷题之路第37天之解数独
  • 1007:计算(a+b)×c的值
  • 事件的传递
  • java基础知识21 异常处理try与throw的相互处理e.getcause
  • 第一讲 递推与递归
  • 【qt qtcreator使用】【正点原子】嵌入式Qt5 C++开发视频
  • 一些swift问题
  • 高频电子线路---倍频器与振荡器
  • dijkstra
  • 【软服之家-注册安全分析报告-无验证方式导致安全隐患】
  • 2-140 基于Solidworks和Matlab Simulink Simscape仿真的机器人手臂仿真
  • Go-Sqlite3学习
  • 吞吐量最高飙升20倍!破解强化学习训练部署难题