上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 18 下一页
摘要: 二分图最大匹配的匈牙利算法:二分图是这样一个图,它的顶点可以分类两个集合X和Y,所有的边关联在两个顶点中,恰好一个属于集合X,另一个属于集合Y。最大匹配:图中包含边数最多的匹配称为图的最大匹配。完美匹配: 如果所有点都在匹配边上,称这个最大匹配是完美匹配。最小覆盖:在一个二分图上用最少的点(x 或 y 集合的都行),让每条连接两个点集的边都至少和其中一个点关联。根据konig定理:二分图的最小顶点覆盖数等于最大匹配数。最小路径覆盖:用尽量少的不相交简单路径(连着n条边)覆盖有向无环图G的所有结点,且任何一个顶点有且只有一条路径与之关联;(如果把这些路径中的每条路径从它的起始点走到它的终点,那么 阅读全文
posted @ 2011-12-22 23:49 追逐. 阅读(330) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1242 读完题第一个想法就是以每个friend的位置为起点依次bfs出step,取最小值。提交后WA,修改再提交TLE。这题是多对一的搜索,反过来就是一对多,第一个搜到的friend所需的step即为最小值。改完后再提交依旧WA...看了下别人的解题报告,基本都是用的优先队列,无奈看了下优先队列的内容,发现也不是想象中那么复杂。在struct中加上了自定义优先级operator<稍微一改便AC了。猛然发现优先队列这么好用... C++提交 Exe.Time31 MS Exe.Memory 288k G+ 阅读全文
posted @ 2011-11-30 17:40 追逐. 阅读(302) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1728 这题主要是解决一个多次访问取最优(转向次数最少)的问题,用vis数组记录每次访问的转向次数,当出现跟优解时此点再次入队。#include<cstdio>#include<queue>#include<iostream>usingnamespacestd;intm,n,lim,si,sj,ei,ej;inttur[5][2]={0,0,0,1,0,-1,-1,0,1,0,};charmap[101][101];intvis[101][101];structnode{i 阅读全文
posted @ 2011-11-29 21:18 追逐. 阅读(301) 评论(0) 推荐(1) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1253 题目不难,简单的BFS加一点剪枝,不过让人郁闷的是用G++提交一直CE,用C++一次AC。最后还是XSY发现的问题,将我保存时间的变量time改成了T然后就A掉了... 这下是记住了,以后再也不用time这名了!#include<cstdio>#include<queue>usingnamespacestd;inta,b,c,T;intmap[51][51][51];inttur[6][3]={-1,0,0,1,0,0,0,-1,0,0,1,0,0,0,1,0,0,-1};st 阅读全文
posted @ 2011-11-29 19:09 追逐. 阅读(235) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1072 一开始看着题目太长,不想读了,就问了下XSY题意。可惜交流了半天也没弄清楚具体细节问题...无奈又回过去重新读了遍题。看来读题还是得自己做啊... 做的BFS题不多,队列的性质还没用熟练。#include<cstdio>#include<queue>#include<cstring>usingnamespacestd;inttur[4][2]={{1,0},{-1,0},{0,1},{0,-1}};structPoint{intx,y,time,step;};int 阅读全文
posted @ 2011-11-26 22:00 追逐. 阅读(272) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1010做的非常恶心的一题,一个脑残错找了N久,剪枝后还是那么慢...#include<iostream>#include<cstdio>usingnamespacestd;charstr[10][10];inttur[4][2]={{-1,0},{1,0},{0,-1},{0,1}};inte,n,m,t,di,dj;intabs(inta){returna<0?-a:a;}voiddfs(inti,intj,intct){if(i==di&&j==dj& 阅读全文
posted @ 2011-11-26 19:29 追逐. 阅读(173) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1372http://poj.org/problem?id=2243 擦了个擦的,N久前在杭电上做的这题0ms,到poj上一交直接超时!poj根本不让用stl啊。。 没办法,只能模拟队列又乱敲了遍。code1:#include<cstdio>#include<queue>usingnamespacestd;charbstr[3],estr[3];intb[2],e[2];inttur[8][2]={-1,-2,1,-2,-2,-1,2,-1,-1,2,1,2,-2,1,2,1};stru 阅读全文
posted @ 2011-11-26 17:51 追逐. 阅读(200) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3628 读完题感觉就是一01背包,仔细想想确又没什么好的思路,感觉只能暴力水水... 看了下discuss里讨论的,写了第一个代码#include<cstdio>#include<cstring>usingnamespacestd;intheg[21];boolf[20000001];intmain(){intn,h,i,j;while(~scanf("%d%d",&n,&h)){intsum=0;intmin=200000000;for(i=0;i<n;i++){scanf 阅读全文
posted @ 2011-11-20 22:03 追逐. 阅读(254) 评论(0) 推荐(0) 编辑
摘要: hdu 2222:#include<cstdio>#include<cstring>#definemm88888#definemn55#defineN26inttire[mm][N];intfail[mm],w[mm],Q[mm];intcg[128];intsize;chartmp[mn],s[1111111];voidbuild(char*word){inti=0,j;for(;*word;++word,i=tire[i][j])if(!tire[i][j=cg[*word]]){memset(tire[size],0,sizeof(tire[size]));w[t 阅读全文
posted @ 2011-11-20 17:56 追逐. 阅读(166) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3661貌似是道很简单的贪心,结果让我搞的。。。唉,不在状态啊...#include<cstdio>#include<cstring>#include<algorithm>usingnamespacestd;intat[1005],bt[1005];intcmp(inta,intb){returna>b;}intmain(){intn,t,i;while(~scanf("%d%d",&n,&t)){intsum=0;for(i=0;i 阅读全文
posted @ 2011-11-19 19:18 追逐. 阅读(227) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 18 下一页