自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

mfcheer

已搬家至:www.mfcheer.com

  • 博客(38)
  • 资源 (1)
  • 收藏
  • 关注

原创 hdu 5492 Find a path【dp】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5492原来公式(n+m-1)* ∑(ai - ai_ave)^2,求公式的最小值,即最小方差路径。 公式展开化简后可以得到 (n+m-1)*s1-s2 s1为ai平方和,s2为和的平方。 dp[i][j][k] 表示 到达i行,j列时,ai的和为k时的最小平方和。代码:#include <ios

2015-09-29 19:08:54 83

原创 ACdream 1099 瑶瑶的第K大

题目链接:点击打开链接题意:求数组第k大的元素,直接排序会超时的,get到 nth_element 这个函数nth_element 用法:nth_element(start, start+n, end)使第n大元素处于第n位置(从0开始,其位置是下标为n的元素),并且比这个元素小的元素都排在这个元素之前,比这个元素大的元素都排在这个元素之后,但不能保证他们是有序的,原理类似快速

2015-09-28 20:25:12 403

原创 hdu 1950 Bridging signals【LIS nlogn】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1950题意:LIS nlogn算法代码:#include <iostream>#include <stdio.h>#include <string>#include <string.h>#include <cmath>#include <queue>#include <vector>#inc

2015-09-28 19:55:18 398

原创 RC4加密算法

代码:#include <iostream>#include <cstring>#include <cstdio>#include <map>#include <algorithm>using namespace std;int S[300];int T[300];int K[300];int main(){ int len; scanf("%d", &len);

2015-09-27 21:00:43 442

原创 LightOJ 1094 - Farthest Nodes in a Tree【树的直径】

树的直径:假设 s-t这条路径为树的直径,或者称为树上的最长路 现有结论,从任意一点u出发搜到的最远的点一定是s、t中的一点,然后在从这个最远点开始搜,就可以搜到另一个最长路的端点。即用两遍搜索就可以找出树的最长路。题目链接: http://www.lightoj.com/volume_showproblem.php?problem=1094题意:树的节点间,路径间边的权值和最大是多少代码:#i

2015-09-24 11:19:15 422

原创 Codeforces Round #321 (Div. 2) ABC

题目链接:http://codeforces.com/contest/580A 求非递减区间的最大长度,递推即可B 按money值由大到小排序,求#include <iostream>#include <stdio.h>#include <string>#include <algorithm> #include <set> #include <map> #include <stri

2015-09-24 10:06:12 324

原创 Vigenere密码 Hill密码

代码:#include <stdio.h>#include <iostream>#include <math.h>#include <stdlib.h>#include <ctype.h>#include <algorithm>#include <vector>#include <string.h>#include <string>#include <queue>#include

2015-09-23 20:16:48 683

原创 IO多路复用之select poll epoll

基本概念  IO多路复用是指内核一旦发现进程指定的一个或者多个IO条件准备读取,它就通知该进程。IO多路复用适用如下场合:  (1)当客户处理多个描述字时(一般是交互式输入和网络套接口),必须使用I/O复用。  (2)当一个客户同时处理多个套接口时,而这种情况是可能的,但很少出现。  (3)如果一个TCP服务器既要处理监听套接口,又要处理已连接套接口,一般也要用到I/O复用。  (4)如果一个服务器

2015-09-23 20:03:05 540

原创 Vernam加密法 Playfair密码加密

#include <stdio.h>#include <iostream>#include <math.h>#include <stdlib.h>#include <ctype.h>#include <algorithm>#include <vector>#include <string.h>#include <string>#include <queue>#include <s

2015-09-23 18:48:42 2531 1

原创 C/C++之回调函数

回调函数就是一个通过函数指针调用的函数。如果你把函数的指针(地址)作为参数传递给另一个函数,当这个指针被用来调用其所指向的函数时,我们就说这是回调函数。回调函数不是由该函数的实现方直接调用,而是在特定的事件或条件发生时由另外的一方调用的,用于对该事件或条件进行响应。函数指针 (1)概念:指针是一个变量,是用来指向内存地址的。一个程序运行时,所有和运行相关的物件都是需要加载到内存中,这就决定了程序运

2015-09-23 11:31:48 424

原创 hdu 2389 Rain on your Parade【最大匹配】

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2389用 Hopcroft-Karp 算法 匈牙利算法会超时代码:#include <stdio.h>#include <iostream>#include <math.h>#include <stdlib.h>#include <ctype.h>#include <algorithm>

2015-09-22 19:54:58 361

原创 hdu 4185 Oil Skimming 【最大匹配】

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4185题意:题意:求给的矩阵中 最多有几个 横着或竖着的 两个相连的“##”裸的最大匹配 数据较水。代码:#include <stdio.h>#include <iostream>#include <math.h>#include <stdlib.h>#include <ctype.h>#

2015-09-22 19:18:48 308

原创 指针函数与函数指针

概念【指针函数】:返回指针的函数。重点是它是一个函数,只是返回值由普通的值或对象变成了指针,也就是说这个函数返回的是一块内存的地址。【函数指针】:指向函数的指针。重点是它是一个指针,只是它指向的内容由普通的变量或对象变成了函数,也就是说它可以指向函数的入口地址。指针函数#include <iostream>using namespace std;class MyType{public:

2015-09-20 23:40:46 73

原创 hdu 4738 Caocao's Bridges【求最小权值的桥】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4738坑: 不连通的,输出0. 图有重边,需要处理。 如果取到的最小值是0的话,要输出1。代码:#include <stdio.h> #include <ctime> #include <math.h> #include <limits.h> #include <complex>

2015-09-16 19:54:25 364

原创 LightOJ 1210 - Efficient Traffic System【强连通图】

题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1210题意: 加多少条边,使得整个图变得强连通。 使用Tarjan进行缩点,得到一个SCC图、 这个图有多少个入度为0的,多少个出度为0的。 假设有n个入度为0,m个出度为0 那么答案是max(n,m) 代码:#include <stdio.h>#include

2015-09-15 01:31:48 555

原创 LightOJ 1003 - Drunk【拓扑排序】

题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1003拓扑排序判圈 ,若存在元素不在拓扑序中,则存在圈。代码:#include <stdio.h>#include <iostream>#include <math.h>#include <stdlib.h>#include <ctype.h>#include <algo

2015-09-15 01:15:57 577 2

原创 LightOJ 1034 - Hit the Light Switches【强连通最小点基】

题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1034题意:有向图,选择尽量少的点,从这些点出发,使得所有点都被到达过。思路:首先,进行强连通缩点。然后每个强连通间按照拓扑排序的思想建边。入度为0的强连通的个数即为答案。代码:#include <stdio.h>#include <iostream>#include <mat

2015-09-14 20:45:57 632

原创 LightOJ 1400 - Employment【稳定婚姻问题】

题目连接:http://www.lightoj.com/volume_showproblem.php?problem=1400代码:#include <stdio.h>#include <iostream>#include <math.h>#include <stdlib.h> #include <ctype.h> #include <algorithm> #include <ve

2015-09-12 13:29:05 770

原创 LA 3989 - Ladies' Choice【稳定婚姻问题】

稳定婚姻学习资料:http://www.matrix67.com/blog/?s=%E7%A8%B3%E5%AE%9A%E5%A9%9A%E5%A7%BB http://www.programmer.com.cn/12001/题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=

2015-09-12 13:20:02 410

原创 hdu 1151 Air Raid 【DAG最小路径覆盖】

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1151DAG最小路径覆盖 = 结点数 - 最大匹配数代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #inclu

2015-09-10 16:24:53 329

原创 hdu 3829 Cat VS Dog【最大独立集】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3829小朋友间建立互斥关系。 只有一个小朋友的集合,用拆点的思想,把每个小朋友拆成2个小朋友,这样在求最大匹配的时候除以2就可以了。就必须建立双向边,比如1和2之间有矛盾,建立1-2矛盾边,2-1矛盾边。最大独立集 = 点数 - 最大匹配数。代码:#include <iostream> #inclu

2015-09-10 11:22:20 334

原创 hdu 3488 Tour【二分图权匹配】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3488本题求最小权匹配,将边权值变为相反数,结果取相反数,KM即可求。代码:#include <stdio.h>#include <ctime>#include <math.h>#include <limits.h>#include <complex>#include <string>#inc

2015-09-10 10:33:58 329

原创 poj 2289 Jamie's Contact Groups【二分 + 最大流】

题目:http://poj.org/problem?id=2289二分分组容量。 建图:源点向人,容量1,分组向汇点,容量为二分值。人向分组,容量为1。代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #

2015-09-09 22:11:32 162

原创 POJ 2112 Optimal Milking【二分+最大流】

题目链接:http://poj.org/problem?id=2112最小化最大流量边。 建图:源点向机器建边,容量为m,牛向汇点建边,容量1,机器与牛之间建边(若符合条件),容量1。代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #inc

2015-09-09 21:22:14 360

原创 二分图多重匹配问题

转自:http://www.cppblog.com/MatoNo1/archive/2011/03/26/142766.html在二分图最大匹配中,每个点(不管是X方点还是Y方点)最多只能和一条匹配边相关联,然而,我们经常遇到这种问题,即二分图匹配中一个点可以和多条匹配边相关联,但有上限,或者说,Li表示点i最多可以和多少条匹配边相关联。二分图多重匹配分为二分图多重最大匹配与二分图多重最优匹配两种,

2015-09-09 18:00:06 1029

原创 LA 3415 - Guardian of Decency【最大独立集】

题目:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1416最大独立集 = 点数 - 最大匹配数解法:按男女分类,不满足4条任何条件的建边,求最大匹配。代码:#include <stdio.h>#include <ctime>#inclu

2015-09-08 21:30:56 371

原创 LA 3126 - Taxi Cab Scheme【DAG最小路径覆盖】

题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1127DAG最小路径覆盖 = 点数 - 最大匹配数。代码:#include <stdio.h>#include <ctime>#include <math.h>#include

2015-09-08 20:41:14 1103

原创 hdu 3879 Base Station【最大权闭合图】

最大权闭合图学习资料:http://www.cnblogs.com/wuyiqi/archive/2012/03/12/2391960.html最大权 = 正的权值的和-建图后的最小割的容量。题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3879题意:有n个点,m个选择,建造n个点各自需要一定花费,每个选择有一定的获利,会选择两个点。求最大的获利代码:

2015-09-08 01:49:42 404

原创 LA 3231 Fair Share 【二分+最大流】

题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1232题意:最小化网络流边中最大流量的最大值。二分流量求值代码:#include <iostream> #include <algorithm> #include <set>

2015-09-07 20:14:16 578

原创 hdu 4280 Island Transport 【网络流+优化】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4280题意:给你点坐标,由右下角向左上角走的最大流。卡时间代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #

2015-09-07 00:26:44 336

原创 hdu 4289 Control【最小割+拆点】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4289代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #include <sstream> #inclu

2015-09-05 18:15:40 313

原创 poj 2195 Going Home【zkw费用流】

题目链接:http://poj.org/problem?id=2195题意:每个人都走到一个屋子的最小花费。二分图类型代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #include <sstream>

2015-09-05 12:37:53 341

原创 zkw费用流模板

模板: 对二分图类型效率高// hdu 3667#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #include <sstream> #include <stdio.h> #include <mat

2015-09-05 03:15:24 411

原创 hdu 3667 Transportation【费用流 + 拆边】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3667解法:大白书366页,拆边法SPFA代码(AC):#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #incl

2015-09-05 03:12:47 351

原创 SGU 194. Reactor Cooling【无源汇上下界最大流】

题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=194当所有附加边全部满流时(即maxflow==所有du[]>0之和),有可行解。代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #i

2015-09-04 23:42:29 551

原创 LightOJ 1177 - Angry Programmer【最大流最小割】

题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1177题意为求最小割。由最小割最大流定理 :最小割 ==》最大流代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #incl

2015-09-02 19:33:48 438

原创 LightOJ 1176 - Getting a T-shirt【最大流】

题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1176建图:源点向人,人向6*n个衣服,衣服向汇点,容量均为1。代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #incl

2015-09-02 00:03:30 363

原创 LightOJ 1155 - Power Transmission【拆点网络流】

题目链接:http://www.lightoj.com/volume_showproblem.php?problem=11551~N每个点有容量限制,这样就把每个点拆开,容量为限制的容量。代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #in

2015-09-01 22:18:20 399

g++编译器for c++

g++编译器 c++ this is a program for C++

2014-10-24

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除