- 博客(15)
- 收藏
- 关注
原创 CF 199 div2 B题
大水题,如果给的step走完了,但是没走到终点的话,还要继续走。比赛wa掉了B. Xenia and Spiestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandar
2013-09-08 11:00:24 734
原创 hdu 3433
A Task ProcessTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1171 Accepted Submission(s): 585Problem DescriptionThere are two ki
2013-09-07 08:25:38 791
原创 poj 3107(简单的树形dp)
mx=max(mx,n-num[u]);就是这个转移方程。。。。。 #include#include#includeusing namespace std;const int maxedge=50005;struct node{ int v,next;}edge[maxedge*2];int edgehead[maxedge],vis[maxedge],k
2011-06-09 20:30:00 831
原创 poj 3104(二分,注意int类型的取值范围)
在0和最大值之间二分查找时间,因为数据太多了,必须二分来求。。。。。。在二分的时候如果是int类型的变量,会让mid=(left+right)/2;时超出int范围,所以需要用64位的变量来写。。。 #include #includeusing namespace std;int a[100010];int main(){ int n,k,i,maxw=-1;
2011-06-05 19:18:00 705
原创 poj 3102(暴力枚举)
很水。。。看了别人的题解之后,也用了暴力。。。 #include#include#include#includeusing namespace std;const double inf=1e15;const double e=1e-6;int x[210],y[210];double maze[210][210];double dis(int i,int
2011-06-05 13:17:00 870
原创 poj 3177(万恶的双连通)
之前写那个3352的时候,自己写了一个双连通算法,可用在这里,无限WA。。。。重边问题呀。。。这个题解决了重边问题,就可以应用双连通算法简单写出来了,题解可以参考3352那个题的解题讲解。。。(这个双连通算法是看了刘汝佳的黑书写出来的,唉。。。) #include #include #include #include #include using namespace
2011-06-04 21:32:00 495
原创 poj 3352(无向图的双连通分量)
刚开始的时候习惯性的套用了以前的代码------有向图的 tarjan 算法, WA。。。。。意识到无向图的双连通和有向图的强连通是不能互换的,想搜一些讲解来看看,找不到好的资料,只好自己把tarjan算法的原理好好看以了一遍,然后在这个算法的基础上,加以改变,来算出双连通分量,然后关于割点的处理可以参考这个博客的讲解,http://www.byvoid.com/blog/biconnec
2011-06-03 15:49:00 1094
原创 POJ 3122(二分算法)
<br />第一次写二分的题,幸好这个题卡的不严,就马马虎虎过了。。。。。<br />代码很简单 不说什么了。。。。<br /> <br /> <br /> <br /> <br />#include <cstdlib>#include<cstdio>#include<cstring>using namespace std;const double PI=3.1415926535897932;const double ln=1e-5;double sum;double a[1
2011-06-02 13:30:00 749
原创 poj 2186(tarjan 算法实现)
<br />刚开始没怎么想,就直接tarjan,然后处理缩点的时候出错了。。。。贡献了2次WA。。。。冷静下来 好好想了想 感觉应该是这样的:<br /> <br />找到缩点以后,计算一下缩点的出度,在这里,不能有两个以上的缩点的出度为0,因为<br /> <br /> compute the number of cows that are considered popular by every other cow. 然后计算一下,出度为0的缩点内有多少个<br /> <br />定点就是题
2011-05-30 20:37:00 513
原创 poj 3041(匈牙利)
<br />这个没什么好说的。。。懂这个算法救知道。。这个水题很简单了。。。。<br /> <br />#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int maxlen=505;int maze[maxlen][maxlen],match[maxlen];bool vis[maxlen];int crosspath(int x){ int i,k;
2011-05-28 21:10:00 400
原创 poj 3020(匈牙利算法的简单应用,关键是构图)
<br />貌似临接矩阵也是可以的,不过习惯用临接表了,直接用的临接表。。。。。<br />构图的时候为了避免边的覆盖,选择 i * m + j 这种方式(看题解的时候看到的,刚开始自己直接来构图,WA) 之后就是简单的匈牙利算法。。。。刚学会。。。看到非递归的那个代码长度。。。。直接递归了。。。。<br /> <br />上代码:<br />#include <iostream>#include<cstdio>#include<cstring>using namespace std;s
2011-05-28 21:06:00 637
原创 poj 2983 (spfa写的查分约束)
刚开始的时候,没想到怎么设置源点,wa了几次,后来看到有用0点做源点的,试了一下,AC!!!#include using namespace std;const int Max=100002;struct node{ int v,c,next;}edge[Max*3];int edgehead[1002],vis[1002],dis[1002],k=0;int q[Max],head=0,rear=0;int cnt[1002];void addedge(int u
2011-05-18 16:56:00 539
原创 poj 1201(spfa)
<br />看到一篇文章介绍查分约束系统的http://imlazy.ycool.com/post.1702305.html 讲的特别好,然后想起很早以前看到过的这个题,做了一下,AC!!!<br /> <br /> 简单说一下我的理解: 对这个题来说,就是找到足够多的约束条件,然后根据条件,运用spfa找最长路就可以了,好像差分约束系统就是一个条件比较多的最短路(或者最长路),这个题的条件有【i , i】=0;【i+1 ,i 】= -1;dis【v】>=dis[u]+maze[u].len; 以及
2011-05-17 20:20:00 452
原创 poj 2553 (tarjan的应用)
<br />趁着刚学这个算法,就连续刷刷。。。掌握才是关键。。。<br />这个题刚开始怎么也看不懂,后来在discuss里看到网友们有说“if for every node w in G that is reachable from v, v is also reachable from w.”这句很重要的时候 ,豁然开朗呀。。。只怪自己没怎么认真看题呀<br /> <br />/* * 关于sink:如果v可以到达w,那么w一定要能到达v;如果到不了,也是可以的。 * 这就是那
2011-05-15 21:46:00 333
原创 poj 1236(tarjan算法)
<br />刚学的tarjan算法,很好的一篇文章http://www.byvoid.com/blog/scc-tarjan/ 看的时候要用心呀,可以很快学会的,然后做了这个题,就会得心应手了。。。。加油<br /> <br /> 第一个输出是生成树的最少个数,然后第二个是添加几条边可以成为强连通图,<br /> <br />#include <cstdlib>#include <iostream>using namespace std;int dfn[102],low[102],bel
2011-05-15 16:08:00 881
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人