随笔分类 -  图论

摘要:G -QS Network读懂题意,就都是是水题#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <algorithm> #define N 1001 const int maxn=(N*N-N) / 2 + 1; using namespace std; struct edge { int x, y, value; }edge[maxn]; int n, len, 阅读全文
posted @ 2013-04-20 14:16 bo_jwolf 阅读(173) 评论(0) 推荐(0)
摘要:I -Arctic Network#include<iostream> #include<algorithm> using namespace std; const int maxn=6000; int n; int mapp[maxn][maxn]; struct node { int x,y,value; }edge[maxn]; int fa[maxn]; bool cmp(const node a,const node b) { return a.value<b.value; } int find(int x) { return x==fa[x]?x:fi 阅读全文
posted @ 2013-04-19 20:57 bo_jwolf 阅读(172) 评论(0) 推荐(0)
摘要:B -Network这个题目真坑,用G++居然TLE,用c++ 直接A了,还好在poj直接过了,否则,找错误不得找死啊!!!!#include<iostream> #include<algorithm> using namespace std; const int maxn=15001; struct node { int x,y,value; }edge[maxn]; int fa[maxn]; int find(int x) { return x==fa[x]?x:find(fa[x]); } bool cmp(const node a,const node b) 阅读全文
posted @ 2013-04-19 15:23 bo_jwolf 阅读(160) 评论(0) 推荐(0)
摘要:J -Agri-Net#include<iostream> #include<algorithm> using namespace std; const int maxn=101; struct node { int x,y,value; }edge[maxn*maxn]; int fa[maxn]; int k; int find(int x) { return x==fa[x]?x:find(fa[x]); } bool cmp(const node a,const node b) { return a.value<b.value; } int main() 阅读全文
posted @ 2013-04-19 14:37 bo_jwolf 阅读(165) 评论(0) 推荐(0)
摘要:E - Networking#include<iostream> #include<algorithm> using namespace std; const int maxn=2000; struct node { int x,y,value; int flag; }edge[maxn]; int fa[maxn]; int find(int x) { return x==fa[x]?x:find(fa[x]); } bool cmp(node a,node b) { return a.value<b.value; } int main() { int m,n, 阅读全文
posted @ 2013-04-19 14:04 bo_jwolf 阅读(177) 评论(0) 推荐(0)
摘要:第一次完整的写出图论中最小路径中常使用的Kruscal和Prim两种算法,呵呵。。。不过我还是比较kruscal(代码比较短,还容易记)C -Jungle Roads// File Name: tulun_jungle.cpp // Author: rudolf // Created Time: 2013年04月18日 星期四 20时57分16秒 //kruscal #include<vector> #include<list> #include<map> #include<set> #include<deque> #include& 阅读全文
posted @ 2013-04-18 22:52 bo_jwolf 阅读(145) 评论(0) 推荐(0)