2017年8月21日
摘要: Given an array containing a permutation of 1 to n, you have to find the minimum number of swaps to sort the array in ascending order. A swap means, yo 阅读全文
posted @ 2017-08-21 10:13 Beserious 阅读(180) 评论(0) 推荐(0)
摘要: 题目描述 有N(1<=n<=1000)头奶牛,它们都被标记上一个优先等级编号1,2,3...用来表示它们喝水的优先次序,编号为1的先喝水,编号2的其次。 每天奶牛开始时排成一排,但总是很乱,你要把它们重新排成编号为1的在前,编号为2的其次.... 你能计算出最少需要多少次的交换次序来完成这次重拍吗? 阅读全文
posted @ 2017-08-21 09:28 Beserious 阅读(212) 评论(0) 推荐(0)