5320: Knowledge Test about Match

内存限制:512 MB 时间限制:10.000 S
评测方式:文本比较 命题人:
提交:7 解决:0

题目描述

It's classical to match two arrays to minimize the loss function, such as Network flow and Kuhn-Munkres algorithm. Here comes a small test.
You are given two sequences a,b with length n.
a = {0,1,2,...,n-2,n-1},b = {b_0,b_1,...,b_n-2,b_n-1}.
Now you are allowed to rearrage sequence b arbitrarily. Formally, you can assign a permutation p between 0 to n-1 and do the following transformation:b_i' = b_pi.
Finally you should minimize the loss function



Because the time limit is too strict to solve, you don't need to find the exact value of f(a,b).Denote the minimal value is f_k* and your result is f_k^ (where k means the k-th test case), you will be accepted if:



输入

输出

For each test case, output n integers in a line, indicating the sequence b after rearranging.

样例输入 复制

2
10
4 8 9 9 6 1 3 9 5 2
54
0 0 0 1 2 2 4 4 5 6 7 10 16 17 18 19 19 20 23 24 25 26 26 26 27 29 30 30 31 32
32 33 34 36 37 37 38 39 41 42 42 43 43 44 44 45 45 46 50 50 51 53 53 53

样例输出 复制

9 1 2 3 4 5 6 9 8 9
0 1 2 2 4 5 6 7 4 0 10 0 53 43 32 30 16 17 18 19 20 19 26 23 24 25 26 27 26 29
30 31 32 33 34 37 36 37 38 39 42 41 42 43 44 45 46 45 44 50 50 51 53 53

提示



•题目大意

         随机生成一个权值范围为 0~n-1 的序列,你要用 0~n-1 去和它匹配,匹配函数是 sqrt。

         要求平均情况下和标准值偏差不能超过 4%。

•考察内容
         贪心,乱搞,匹配
spj假了,提交请点击下方链接
K-Knowledge Test about Match_2021牛客暑期多校训练营1 (nowcoder.com)