【算法】数学置换 【题意】给定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://codeforces.com/problemset/problem/842/D 题意:给你n个数,m次查询,每次将数组全部异或一个数后,求没出现过的最小自然数 要求异或后的最小值我们可以用字典树来解决 而每次对数组异或可以替换每次对异或值异或 之后贪心的选取 每次都走左子树,如果 ...
分类:
其他好文 时间:
2017-09-18 20:32:06
阅读次数:
149
http://acm.hdu.edu.cn/showproblem.php?pid=6215 题意:给出一个序列,对于每个数,它必须大于等于它前一个数,小于等于后一个数,如果不满足,就删去。然后继续去判断剩下的数,直到最后都满足。 思路: 建立双向链表,如果一个数是需要删除的,那么它只会影响它前一个 ...
分类:
其他好文 时间:
2017-09-18 20:29:10
阅读次数:
190
Description Last years Chicago was full of gangster fights and strange murders. The chief of the police got really tired of all these crimes, and deci ...
分类:
其他好文 时间:
2017-09-18 10:55:43
阅读次数:
219
题目链接: 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
题目大意: 定义mex数为数组中第一个没有出现的非负整数.有m个操作,每个操作有一个x,将数组中所有的元素都异或x,然后询问当前的mex Input First line contains two integer numbers n and m (1?≤?n,?m?≤?3·105) — number ...
分类:
其他好文 时间:
2017-09-08 14:53:49
阅读次数:
197
Description Last years Chicago was full of gangster fights and strange murders. The chief of the police got really tired of all these crimes, and deci ...
分类:
其他好文 时间:
2017-09-05 23:00:38
阅读次数:
258