【算法】数学置换 【题意】给定n个数,要求通过若干次交换两个数的操作得到排序后的状态,每次交换代价为两数之和,求最小代价。 【题解】 考虑置换的定义:置换就是把n个数做一个全排列。 从原数组到排序数组的映射就是经典的置换,这样的置换一定能分解成循环的乘积。 为什么任意置换都可以这样分解:原数组的每个 ...
分类:
编程语言 时间:
2017-09-21 19:30:57
阅读次数:
138
Brute Force Sorting Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1204 Accepted Submission(s): ...
分类:
其他好文 时间:
2017-09-20 00:34:48
阅读次数:
248
1697: [Usaco2007 Feb]Cow Sorting牛排序 Description 农夫JOHN准备把他的 N(1 <= N <= 10,000)头牛排队以便于行动。因为脾气大的牛有可能会捣乱,JOHN想把牛按脾气的大小排序。每一头牛的脾气都是一个在1到100,000之间的整数并且没有两 ...
分类:
编程语言 时间:
2017-09-19 18:31:12
阅读次数:
230
http://acm.hdu.edu.cn/showproblem.php?pid=6215 题意:给出一个序列,对于每个数,它必须大于等于它前一个数,小于等于后一个数,如果不满足,就删去。然后继续去判断剩下的数,直到最后都满足。 思路: 建立双向链表,如果一个数是需要删除的,那么它只会影响它前一个 ...
分类:
其他好文 时间:
2017-09-18 20:29:10
阅读次数:
190
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5122 Problem Description Matt’s friend K.Bro is an ACMer.Yesterday, K.Bro learnt an algorithm: Bubble ...
分类:
其他好文 时间:
2017-09-15 23:44:00
阅读次数:
256
Description 农夫JOHN准备把他的 N(1 <= N <= 10,000)头牛排队以便于行动。因为脾气大的牛有可能会捣乱,JOHN想把牛按脾气的大小排序。每一头牛的脾气都是一个在1到100,000之间的整数并且没有两头牛的脾气值相同。在排序过程中,JOHN 可以交换任意两头牛的位置。因为 ...
分类:
编程语言 时间:
2017-09-01 09:47:06
阅读次数:
98
A. Sorting by Subsequences You are given a sequence a1,?a2,?...,?an consisting of different integers. It is required to split this sequence into the m ...
分类:
其他好文 时间:
2017-08-29 14:17:28
阅读次数:
180
You are given a sequence a1,?a2,?...,?an consisting of different integers. It is required to split this sequence into the maximum number of subsequenc ...
分类:
编程语言 时间:
2017-08-25 21:01:04
阅读次数:
780
843A - Sorting by Subsequences 还好之前了解过一点白书上的permutation! 我写的递归,其实很容易直接写成递推啊 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn=1e5+10; ...
分类:
其他好文 时间:
2017-08-25 11:04:49
阅读次数:
224