B. Multitasking CF_384

来源:互联网 发布:x战警 跑错片场 知乎 编辑:程序博客网 时间:2024/05/16 19:08

题意:

Iahub wants to enhance his multitasking abilities. In order to do this, he wants to sort n arrays simultaneously, each array consisting of mintegers.

Iahub can choose a pair of distinct indices i and j (1 ≤ i, j ≤ m, i ≠ j). Then in each array the values at positions i and j are swapped only if the value at position i is strictly greater than the value at position j.

Iahub wants to find an array of pairs of distinct indices that, chosen in order, sort all of the n arrays in ascending or descending order (the particular order is given in input). The size of the array can be at most  (at most  pairs). Help Iahub, find any suitable array.

Thinking:

一开始想的特别复杂,用到数组啊函数啊

     给n个含m个序列的数组,选择第i j 列,当且仅当a[x][i]>/<a[x][j]时才可以调换,最高次数是m*(m-1)/2。问在小于等于m*(m-1)/2个步骤中k==0升序,k==1降序。

蠢货!!!在看到m*(m-1)/2竟然没有条件反射,m个数字最多的排列数也是 m*(m-1)/2,所以只要排列这么多次就一定可以完成。竟然想要用数组然后去重排列TT....

and then 题目可以转化成多维数组!


0 0