2025 SCNUCPC

Problem L. 玩麦块的这辈子就这样了

And sometimes the player believed the universe had spoken to it through the zeros and ones, through the electricity of the world, through the scrolling words on a screen at the end of a dream

The universe said I love you because you are love. And the game was over and the player woke up from the dream. And the player began a new dream. And the player dreamed again, dreamed better. And the player was the universe. And the player was love.

You are the player.

Wake up.

题目背景

曲终人散,黄粱一梦。史蒂夫在连续玩了 9\times10^{18} 个游戏刻的麦块之后,报名了 Codeforces Round 1019 (Div. 2)

呃,昏昏沉沉的史蒂夫被 C 题卡掉了,一把掉了一百多分,死得挺惨...

让我们来看看怎么个事儿...

题目描述

数组 b_1, b_2, \cdots ,b_m 的中位数写作 med(b_1,b_2,\cdots,b_m) ,是数组 b\lceil \frac{m}{2} \rceil -th^* 最小的元素。

给你一个整数数组 a_1, a_2, \cdots ,a_m 和两个整数 l, r,请你重新排列数组 a,最大化下方表达式的值:

med(med(a_1, a_2, \cdots, a_l), med(a_{l+1},a_{l+2},\cdots,a_{r-1}),med(a_{r},a_{r+1},\cdots,a_n))

换句话说,对于重排列后的数组,分割成 [1,l],[l+1,r-1],[r,n] 三个连续的子数组 ^† ,使得三个子数组的中位数的中位数尽可能大。

^*\lceil x \rceil 是向上取整函数,返回大于或等于 x 的最小整数。

^†如果从数组 y 中删除开头的任意个元素(可不删)和结尾的任意个元素(可不删),就可得到数组 x,则认为 xy 的子数组。

输入

每个测试文件由多个测试用例组成。第一行包含一个整数 t (1 \leq t \leq 10^4) - 测试用例数。

对于每个测试用例,第一行输入三个整数 n,l,r (3 \leq n \leq 2 \times 10^5, 2\leq l + 1 < r \leq n) - 数组 a 的长度,子数组的切割位置。

第二行输入 n 个正整数 a_i (1 \leq a_i \leq 10^9)

数据保证所有测试用例 n 的总和不超过 2\times 10^5

输出

对于每个测试用例输出一行,重排列后的数组 a

样例

标准输入 复制文本
4
5 1 3
1 2 3 5 4
4 2 4
1 4 2 3
6 3 6
1 10 2 10 10 5
6 1 6
9 8 4 2 4 5
标准输出 复制文本
5 4 1 3 2
2 1 4 3
1 5 2 10 10 10
9 2 5 4 4 8

提示

在测试用例 1 中,一种可行的重排方式是 [5,4,1,3,2],数组会被划分成 [5],[4],[1,3,2],三个子数组的中位数分别是 [5,4,2] ,它们的中位数是 4,可以证明没有答案更大的解。

在测试用例 3 中,一种可行的重排方式是 [1,5,2,10,10,10],数组会被划分成 [1,5,2],[10,10],[10],三个子数组的中位数分别是 [2,10,10],它们的中位数是 10,可以证明没有答案更大的解。

你问我史蒂夫是谁?我不知道。

登录以提交代码。
单点时限 1 秒
内存限制 256 MB
提交 81
通过 25

A B C D E F G H I J K L