给出一个序列,每次交换两个数,求有几种交换方法能使序列变成升序. n不大于5,用dfs做. 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int num[8], ans, n; bool check() { //check if the array is inorder for (int i = 0; i < n - 1; i++) if (nu…
题目例如以下: Mapping the Swaps  Sorting an array can be done by swapping certain pairs of adjacent entriesin the array. This is the fundamental technique used in the well-knownbubble sort. If we list the identities of the pairs to be swapped, in thesequen…
Mapping the Swaps Sorting an array can be done by swapping certain pairs of adjacent entries in the array. This is the fundamental technique used in the well-known bubble sort. If we list the identities of the pairs to be swapped, in the sequence the…
这道题目甚长, 代码也是甚长, 但是思路却不是太难.然而有好多代码实现的细节, 确是十分的巧妙. 对代码阅读能力, 代码理解能力, 代码实现能力, 代码实现技巧, DFS方法都大有裨益, 敬请有兴趣者耐心细读.(也许由于博主太弱, 才有此等感觉). 题目: UVa 1103 In order to understand early civilizations, archaeologists often study texts written in  ancient languages. One…
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=251  Network  A Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting several places numbered by integers…
旋转卡壳求凸包直径. 参考:http://www.cppblog.com/staryjy/archive/2010/09/25/101412.html #include <cstdio> #include <cmath> #include <algorithm> using namespace std; << ; struct Point { int x, y; Point( , ):x(x), y(y) { } }; typedef Point Vecto…
Critical Links  In a computer network a link L, which interconnects two servers, is considered critical if there are at least two servers A and B such that all network interconnection paths between A and B pass through L. Removing a critical link gen…
 Network  A Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting several places numbered by integers from 1 to N. No two places have the same number. The lines are bidirectional and always connect together t…
由于涉及到实数,一定,一定不能直接等于,一定,一定加一个误差<0.00001,坑死了…… 有两种事物,不难想到用二分图.这里涉及到一个有趣的问题,这个二分图的完美匹配的最小权值和就是答案.为啥呢?因为如果有四个点,a,b,c,d .Ab和cd交叉,ac和bd不交叉,那么ac和bd的长度和一定小于ab和cd的长度和,可以画一个图很容易就证出来.所以,如果所有的边都不交叉,又因为有解,那么最小的权值和就是解了.附图一枚,自己画的,比较简陋,凑活着看吧…… 用KM算法求最佳完美匹配最小权值和,可以直接…
题目大意:给你一个网络要求这里面的桥. 输入数据: n 个点 点的编号  (与这个点相连的点的个数m)  依次是m个点的   输入到文件结束. 桥输出的时候需要排序   知识汇总: 桥:   无向连通图中,如果删除某条边后,图变成不连通了,则该边为桥. 求桥: 在求割点的基础上吗,假如一个边没有重边(重边 1-2, 1->2 有两次,那么 1->2 就是有两条边了,那么 1->2就不算是桥了). 当且仅当 (u,v) 为父子边,且满足 dfn[u] < low[v] 这里对重边处理…