欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2048B.Kevin and Permutation
Kevin and Permutation
Kevin is a master of permutation-related problems. You are taking a walk with Kevin in Darkwoods, and during your leisure time, he wants to ask you the following question.
Given two positive integers and , construct a permutation of length to minimize the sum of the minimum values of all subarrays of length . Formally, you need to minimize
$$um_{i=1}^{n-k+1}\left( \min_{j=i}^{i+k-1} p_j\right).$$</p><div class="statement-footnote"><p>$^{\text{∗}}$A permutation of length$n$is an array consisting of$n$distinct integers from$1$to$n$in arbitrary order. For example,$[2,3,1,5,4]$is a permutation, but$[1,2,2]$is not a permutation ($2$appears twice in the array), and$[1,3,4]$is also not a permutation ($n=3$but there is$4$in the array). </p><p>$^{\text{†}}$An array$a$is a subarray of an array$b$if$a$can be obtained from$b$ by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. Two subarrays are considered different if the sets of positions of the deleted elements are different. ## Input Each test consists of multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^3$). The only line of each test case contains two integers $n$ and $k$ ($1\le k\le n\le 10^5$). It is guaranteed that the sum of $n$ over all test cases doesn't exceed $10^5$. ## Output For each test case, output $n$ integers on a single line — the permutation $p$ you constructed. If there are multiple answers, you can print any of them. ## Note In the first test case, with $k=2$, consider all subarrays of length $2$: the minimum value of $p_1,p_2$ is $1$, the minimum value of $p_2,p_3$ is $1$, and the minimum value of $p_3,p_4$ is $2$. The sum $1+1+2=4$ is the smallest among all possible permutations. In the second test case, all subarrays of length $1$ have minimum values of $5, 2, 1, 6, 4, 3$, and the sum $5+2+1+6+4+3=21$ is proven to be the smallest. ## Samples ```input1 3 4 2 6 1 8 3 ``` ```output1 3 1 2 4 5 2 1 6 4 3 4 6 2 8 3 1 5 7 ```$$在线编程 IDE
建议全屏模式获得最佳体验
键盘快捷键
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |
第 1 行,第 1 列
0 字符
-
最近自测结果
暂未运行
最近递交结果
暂无递交记录