- 博客(41)
- 资源 (3)
- 收藏
- 关注
原创 HDU 1542
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1542求图形的面积。线段树。仿照别人的思想搞的。http://www.cnblogs.com/ka200812/archive/2011/11/13/2247064.html下面是AC代码:#include#includeusing namespace std;struct
2012-09-28 17:27:16 1436
原创 RMQ with Shifts
RMQ with ShiftsIn the traditional RMQ (Range Minimum Query) problem, we have a static array A. Then for each query (L, R)(LR), we report the minimum value among A[L], A[L + 1], ..., A[R]. Note
2012-09-27 08:50:55 2281
原创 售票系统
247. 售票系统★★☆ 输入文件:railway.in 输出文件:railway.out 简单对比时间限制:1 s 内存限制:128 MiB【问题描述】某次列车途经C个城市,城市编号依次为1到C,列车上共有S个座位,铁路局规定售出的车票只能是坐票, 即车上所有的旅客都有座。售票系统是由计算机执行的,每一个售票申请包含三个参数,分别用O、D、N表示,O为
2012-09-26 10:44:01 2364 2
原创 数列操作
264. 数列操作★☆ 输入文件:shulie.in 输出文件:shulie.out 简单对比时间限制:1 s 内存限制:16 MiB【问题描述】 假设有一列数 {Ai }(1 ≤ i ≤ n) ,支持如下两种操作:(1)将 A k 的值加 D 。( k, D 是输入的数)(2) 输出 A s +A s+1 +…+A t 。( s, t 都是
2012-09-25 15:00:36 1181
原创 均衡队形
182. [USACO Jan07] 均衡队形★★ 输入文件:lineup.in 输出文件:lineup.out 简单对比时间限制:1 s 内存限制:128 MiB题目描述农夫约翰的 N (1 ≤ N ≤ 50,000) 头奶牛,每天挤奶时总会按同样的顺序站好。一日,农夫约翰决定为奶牛们举行一个“终极飞盘”比赛。为简化问题,他将从奶牛队列中选出一个连
2012-09-25 14:57:54 790
原创 poj 2777
题目:http://poj.org/problem?id=2777线段树。线段覆盖+lazy标记。处理查询的时候要注意。不要查询到最下面的子树,不然会超时下面是AC代码:#include#include#include#includeusing namespace std;const int maxn = 100000+10;#define lson id<<1,l
2012-09-25 10:12:57 553
原创 ZOJ 1610
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=610线段树。线段覆盖。成段更新。lazy标记处理。下面是AC代码:#include#include#includeusing namespace std;const int maxn = 10000;struct node{ i
2012-09-24 16:34:32 1625
原创 hdu 308
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3081并查集+二分图最大匹配。。关键就是朋友之间的关系处理。。每次找最大匹配。看能否最大匹配==n。删掉匹配过的边。下面是AC代码:#include#includeusing namespace std;const int maxn = 110;bool g[maxn][maxn];
2012-09-13 15:52:32 673
原创 hdu 1532
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1532直接用EK()算法求最大流。下面是AC代码:#include //EK()算法。时间复杂度(VE^2)#include#includeusing namespace std;const int maxn = 205;const int INF = (
2012-09-13 09:49:24 1362
原创 最大流EK算法模板
#include //EK()算法。时间复杂度(VE^2)#include#includeusing namespace std;const int maxn = 100;const int INF = (1<<30)-1;int g[maxn][maxn];int flow[maxn],pre[maxn];bool vis[maxn];int n,m;int b
2012-09-13 09:21:51 2158
原创 最小生成树(模板)
kruskal算法:#includeusing namespace std;struct edge{ int x,y,c;};edge elist[250010];int n,m,i,j,ans,num,psum;bool hash[250010],bk;int zu[501],e[501];int cmp(const void *s,const void *
2012-09-13 08:46:43 794
原创 最短路径问题(算法模板)
最短路径问题,具体可以用dijkstr算法,ford算法。。还有SPFA等等。然后各种 算法在实际问题又有区别。SPFA在稀疏图上快,因为是通过边来增广的。dijkstra在稠密图上快。因为是通过点来增广的。某些情况下dijkstra 加上 堆优化 在处理大数据的时候会比SPFA快很多。但是SPFA在随机数据的综合表现中相比dijkstra优势还是比较大的。spfa算法
2012-09-13 08:44:54 783 1
原创 匈牙利算法模板
#include#includeusing namespace std;const int maxn = 110;bool g[maxn][maxn];int match[maxn];bool vis[maxn];int n;bool dfs(int cur){ for(int i=1;i<=n;i++){ if(g[cur][i]==true&&!v
2012-09-13 08:39:25 949
原创 KM算法模板
#include#includeusing namespace std;const int maxn = 305;const int INF = (1<<30)-1;int g[maxn][maxn];int lx[maxn],ly[maxn];int match[maxn];bool visx[maxn],visy[maxn];int slack[maxn];int n;b
2012-09-13 08:38:10 1964
原创 HDU 3315
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3315二分图的最优匹配。图很容易建立。再处理相似度的时候。把每个权值扩大100倍。然后再对i==j时 特殊标记。使他们的权值再++1。后面选择的时候就很容易挑出。按原匹配匹配的个数。 100*(double)(res%100)/n。即可得到第二问。下面是AC代码:#inclu
2012-09-12 18:02:06 941
原创 hdu 2236
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2236二分+最大匹配。 先二分枚举差值的,然后枚举下限制。看能不能再这个区间内实现最大匹配。如果能继续搜索更小的值。下面是AC代码:#include#includeusing namespace std;const int maxn = 110;int g[maxn][ma
2012-09-12 17:09:46 982
原创 hdu 2448
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2448最短距离+二分图最优匹配。 先计算各个采矿点的最短距离。 同时题目也给出n个船的起始所在的位置。那么就可以计算出每个船由起始点出发,或到其他采矿点然后在去码头(或直接去码头)的最短距离。 然后二分最优匹配(KM算法)。即可求出最小值。下面是AC代码:#include#includ
2012-09-12 15:29:35 745
原创 HDU 2282
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2813直接用map映射为序号建图。。套用KM算法模板即可下面是AC代码:#include#include#include#include#includeusing namespace std;const int maxn = 205;const int INF = (1<<
2012-09-12 11:11:01 823
原创 hdu 3395
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3395直接按题意建图。KM算法求解。#include#includeusing namespace std;const int maxn = 105;const int INF = (1<<30)-1;int g[maxn][maxn];int lx[maxn],ly[maxn];in
2012-09-12 10:22:04 682
原创 hdu 2282
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2282将题目的问题转化成 以每个盒子里多余的巧克力,到空盒子的最优匹配问题。下面是AC代码:#include#include#include#includeusing namespace std;const int maxn = 505;const int INF = (1<<3
2012-09-12 10:20:01 754
原创 HDU 3722
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3722二分图的最优匹配。 直接按N个字符和这N个字符反串进行建图。下面是AC代码:#include#includeusing namespace std;const int maxn = 205;const int INF = (1<<30)-1;int g[maxn]
2012-09-11 21:57:11 916
原创 HDU 2389
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2389直接找的一个HK算法模板。 下面是 AC代码://该算法的精髓在于同时找多条增广路进行反转。//我们先用BFS找出可能的增广路,这里用到BFS层次搜索的概念,//记录当前结点在第几层,用于后面DFS沿增广路反转时用,//然后再用DFS沿每条增广路反转。这样不停地找,直
2012-09-11 17:22:49 974
原创 hdu 3718
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3718二分图的最优匹配。关键是模型的架构。(转)题目求的是两字符串的最大相似度 思路:因为第一个串的一种字母只能匹配第二个串的一种字母,所以可以转化为求 【字母的最大匹配值/n】 建图:【例】 下面是AC代码:#include#includeusing n
2012-09-11 16:42:30 678
原创 hdu 2853
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2853二分图的最优匹配。因为题目上的节点最多只有50个。所以先对所有权值*100,把原来各个匹配关系的权值+1,然后在求被改变的个数只需要 用 n-KM()%100;就可以知道被改变的点的个数。最大的增量就用km()-pre_sum.即可。下面是AC代码:#include#
2012-09-11 15:04:39 619
原创 HDU 2426
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2426二分图的最优匹配。用KM算法解决。题目要求找到最大的权值。同时要n个人都要匹配到。注意细节。下面是AC代码:#include#includeusing namespace std;const int maxn = 505;const int INF = (1<<30
2012-09-11 14:28:39 711
原创 hdu 1853 | hdu 3488 | hdu3435
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1853二分图的最优匹配。求最小费用流。要求所有点匹配下的最小费用,直接套用KM算法的即可。。下面是 1853 AC代码:#include#includeusing namespace std;const int maxn = 305;const int INF = (
2012-09-11 12:33:37 520
原创 hdu 1533
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1533求二分图的最优匹配。 求最小费用时,只要将所有费用全部变成负数,然后按照KM算法求最大值。对得到的结果进行取反就可以了。下面是AC代码:#include#include#includeusing namespace std;const int maxn = 105
2012-09-11 11:02:46 864
原创 HDU 2255
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2255二分图的最优匹配(最大权值)。用KM算法解决。纯模板。下面是AC代码:#include#includeusing namespace std;const int maxn = 305;const int INF = (1<<30)-1;int g[maxn][ma
2012-09-11 10:44:53 954
原创 hdu 1498
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1498二分图。求最小点覆盖。和hdu1281类似。。就是把每种颜色单独求最大匹配。看能不能在K次以内全部砸碎。如果>k即为所求。下面是AC代码:#include#include#includeusing namespace std;const int maxn=105;
2012-09-10 22:52:08 986
原创 hdu 1281
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1281二分图。 求二分图的最小覆盖点=二分图的最大匹配。 求某个点是不是重要点。枚举除去这个点(不含这个点的最大匹配个数是否小于含这个点的最大匹配)。下面是AC代码:#include#includeusing namespace std;const int maxn=105
2012-09-10 22:03:50 1181
原创 hdu 1179 |hdu 2063
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1179裸题。。二分图的最大匹配。、下面是1179 AC代码:#include#includeusing namespace std;const int maxn = 110;int n,m,k;int g[maxn][maxn];int match[maxn];
2012-09-10 16:19:47 750
原创 hdu 1054
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1054二分图。求最小顶点覆盖。。因为是无向图求出来的匹配要除以2.。n比较大。所以要用邻接表。用邻接矩阵会超时。下面是AC代码:#include#includeusing namespace std;const int maxn = 1505;int n,m;int g
2012-09-10 16:01:38 559
原创 hdu 1068
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1068求最大独立集 = n (顶点数)- 最大匹配/2(这里的最大匹配因为是无向图,所以除2)(转)本题中的A集合为顶点集,B集合也为顶点集并且例如(1--2)和(2--1)并存,那么接下来我们有两种选择,去掉其中一个,向公式靠拢;或者二者并存,变换一下公式。为了处理的方便,
2012-09-10 15:32:19 608
原创 hdu 1151
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1151二分图最小路径覆盖=点的个数-最大匹配。。下面 是 AC代码:#include#includeusing namespace std;const int maxn = 110;int n,m;int g[maxn][maxn];int match[maxn];bo
2012-09-10 15:14:03 750
原创 HDU 1150
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1150求二分图的最小顶点覆盖,即求二分图的最大匹配。将A,B这两台机器的模式看成 (x,y)两部点集合。即找到这些最小的点覆盖掉K个任务。开始0,0 不用处理。要注意下。下面是AC代码:#include#includeusing namespace std;const in
2012-09-10 14:40:45 893
转载 二分图的基本模型思想
今天突然想到一个关于二分图的灰常xx的比喻,所以赶紧写下来。 假设全班的男生集合为R1,女生集合为R2,男生分别记为m1,m2……女生分别记为w1,w2……。最近全班学生大多数都寂寞了,想谈恋爱了于是大家都在物色目标。其中有不少男女生互相之间都有好感。但一个男生可能对多个女生有好感,一个女生也可能对多个男生有好感(都是花心大萝卜)—————————————————————背景交代
2012-09-10 11:19:12 1887
原创 HDU 1083
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1083二分图的最大匹配。。直接用套用匈牙利算法即可。下面是AC代码:#include#includeusing namespace std;const int maxn = 110;bool g[3*maxn][3*maxn];int match[3*maxn];bo
2012-09-10 11:17:16 841
原创 hdu 1080
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1080、模型很像最长公共子序列类的DP。状态转移方程是 dp [i][j]= max(dp[i-1][j]+val[i]['-'],dp[i][j-1]+val['-'][j],dp[i-1][j-1]+val[i][j]). (val[i][j]为题中权值)dp[i][j]为长度为i的
2012-09-07 22:15:12 1333 1
原创 hdu 1598
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1598可以用并查集,也可以用二分+单元最短距离做。思路都差不多。都是枚举上下界。先将速度排序。然后枚举上界,添加其他节点。如果能使a->b联通,那么当前这个舒适值就是上界-新添加的这个节点(使a-b联通的)。然后求一个最小值就行了。下面是AC代码:#include#incl
2012-09-04 15:31:08 720
转载 英语应该这样去学
写在前面:曾经我也是一个英语始终过不了雅思六分的孩子,国内大学的时候我甚至连三级也过不了,一直到现在,可以在全英文的环境下生活,可以用流利的英文和别人对话,可以用英文做项目.再回头想想这些年走过的这条路,有点辛酸,有点觉得国内的教育实在是太误人子弟,所以有一种冲动,想把自己的一些方法和学习的一些东西介绍给大家,也许对和我曾经一样正在为英语头疼的朋友有一点帮助吧.如果说的不好,也请嘴下留情,
2012-09-03 21:44:38 2027
android studio 中文包
2016-11-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人