随笔分类 - 图论
摘要:尼玛 我今天刚刚知道什么是负权回路 任意相连的无向图之间都是回路!!! 囧了一天了,算是看出来了,渣比 A B 则A能到B且B能到A,这就是一个回路。
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1879
阅读全文
摘要:这题竟然出错在了快排上,对double类型的数据排序, return a>b?1:-1; 如果还是减的话则会造成数据丢失 http://acm.hdu.edu.cn/showproblem.php?pid=1875
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1372 以前真二,模板题 OJ真奇怪,有时能A有时W,
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2896 最小生成树:n个顶点n-1条边 本题因为有50000个点,所以只能用Kuscal
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2144&cid=1186 最小生成树,最重要的是了解思想 稠密图用Prim,稀疏图用Kruskal K(每次找最小的边连接,一条边连接两个点,所以单路就可以了) Prim() #include <s
阅读全文
摘要:当然,对于Spfa判负环,实际上还有优化:就是把判断单个点的入队次数大于n改为:如果总的点入队次数大于所有点两倍 时有负环,或者单个点的入队次数大于sqrt(点数)有负环。这样时间复杂度就降了很多了。 判断给定的有向图中是否存在负环。 利用 spfa 算法判断负环有两种方法: 1) spfa 的 d
阅读全文
摘要:#include#include#includeint k,h[110],mark;struct M{ int data; struct M *next;}*head[110];void init(){ int i; for(i = 0; i next = NULL; ...
阅读全文
摘要:#include#includeint d[15],map[15][15],vis[15];int main(){ int i,j,k,f,n,m,u,v; while(~scanf("%d%d",&n,&m)) { memset(d,0,sizeof(d)); memset(map,0,sizeo...
阅读全文
摘要:Flip Game 思想很不成熟, #include <stdio.h>#include <string.h>#include <stdlib.h>int map[4][4];int ans=100; int f(){ for(int i=0;i<4;i++) { for(int j=0;j<4;j
阅读全文
摘要:比较抽象吧,看到题时一点思想也没有,参考了别人的代码才知道。。。渣渣 #include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>using namespace std;int map[10][10];int
阅读全文
摘要:#include <stdio.h>#include <string.h>int map[51][51][51];int v[51][51][51];int a,b,c,t11;struct node{ int x,y,z,ans;}q[200001];int jx[6]={0,0,0,0,-1,1
阅读全文
摘要:dfs #include <stdio.h> #include <string.h> char Map[16][16]; int mv[16][16]; //mv[i][j] == 0 没有被访问 //mv[i][j] == 1 已经被访问 struct N { int x,y; } ; int j
阅读全文
摘要:http://poj.org/problem?id=3259 Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is ver
阅读全文
摘要:BF是对边进行操作,DJ是对点进行操作。N个顶点的最短路是N-1条边,所以循环N-1次。 学的好吃力。。。自己好渣渣。。。不愧是渣渣二号,还是贴贴思想吧 1,.初始化:将除源点外的所有顶点的最短距离估计值 d[v] ←+∞, d[s] ←0; 2.迭代求解:反复对边集E中的每条边进行松弛操作,使得顶
阅读全文
摘要:被坑了3个小时,本来以为算法错了,谁知道,竟然是素数筛弄错了 !!! #include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>using namespace std;int
阅读全文
摘要:http://poj.org/problem?id=3278 Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 47010 Accepted: 14766 Description Farmer John
阅读全文
摘要:#include <stdio.h>#include <string.h>int map[200][200],v[200],dis[200];int n,s,t;#define N 100001void DJ(){ int i,j,k,min; memset(v,0,sizeof(v)); mems
阅读全文