B. Multitasking CF_384

题意:

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值