随笔分类 -  图论

1

【专题】图的连通性问题
摘要:有向图的强连通分量POJ 1236 - Network of Schools(基础)http://acm.pku.edu.cn/JudgeOnline/problem?id=1236题意:问添加多少边可成为完全连通图解法:缩点,看度数/** head-file **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** define-fo... 阅读全文

posted @ 2013-07-28 19:47 电子幼体 阅读(145) 评论(0) 推荐(0)

poj 2449 k短路--模板
摘要:Remmarguts' DateTime Limit:4000MSMemory Limit:65536KTotal Submissions:17853Accepted:4879Description"Good man never makes girls wait or breaks an appointment!" said the mandarin duck father. Softly touching his little ducks' head, he told them a story."Prince Remmarguts lives i 阅读全文

posted @ 2013-07-24 15:08 电子幼体 阅读(127) 评论(0) 推荐(0)

MUTC7 A-As long as Binbin loves Sangsang
摘要:As long as Binbin loves SangsangTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2053Accepted Submission(s): 501Problem DescriptionBinbin misses Sangsang so much. He wants to meet with Sangsang as soon as possible.Now Binbin downloads a map from ELG 阅读全文

posted @ 2013-07-24 10:43 电子幼体 阅读(206) 评论(0) 推荐(0)

MUTC2013 H-Park Visit-hdu4607
摘要:Park VisitTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 85Accepted Submission(s): 34Problem DescriptionClaire and her little friend, ykwd, are travelling in Shevchenko's Park! The park is beautiful - but large, indeed. N feature spots in the 阅读全文

posted @ 2013-07-23 19:07 电子幼体 阅读(230) 评论(0) 推荐(0)

Codeforces Round #190 (Div. 2) E. Ciel the Commander 题目与题解翻译
摘要:E. Ciel the Commandertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output现在Fox Ciel成为了Tree Land的指挥官。Tree Land,正如它的名字所说,有n个城市由n-1条无向道路连接,并且其中任意两个城市之间总是存在一条路径。Fox Ciel需要在每个城市分配一个官员。每个官员都有一个等级---一个’A’到’Z’之间的字母。所以会有26个不同的等级,’A’是最高的,’Z’是最低的。每个等级都有足够的官员。但是必 阅读全文

posted @ 2013-07-01 18:48 电子幼体 阅读(166) 评论(0) 推荐(0)

树的直径与树的中心
摘要:1. 树的直径概念:树中的最长路。求法:两次深搜或DP。1-两次深搜:任找一点A为源点,深搜遍历得到最远点B,这个最远点B必定在直径中(感性想想,以A点为源点找到的最长路后面一段必定属于树的直径的一部分);再以这个最远点B为源点深搜遍历求一个最长路,这个最长路即为树的直径。2-DP:显然最长路的两个端点必然是叶子或者根节点。设f(i)表示到i最远的叶子,g(i)表示到i次远的叶子,则有f(i)=max{f(j)}+1;g(i)=second{f(j)}+1;其中j必须是i的儿子,计算顺序是自底向上。最终答案为max{f(i)+g(i)}+12. 树的中心概念:树的直径的中点。求法:有多种,如D 阅读全文

posted @ 2013-07-01 16:06 电子幼体 阅读(468) 评论(0) 推荐(1)

MUTC 3 E - Triangle LOVE 图论/搜索
摘要:Triangle LOVETime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1629Accepted Submission(s): 693Problem DescriptionRecently, scientists find that there is love between any of two people. For example, between A and B, if A don’t love B, then B must love 阅读全文

posted @ 2013-06-12 13:38 电子幼体 阅读(156) 评论(0) 推荐(0)

MUTC 2 D - Power transmission 最短路
摘要:Power transmissionTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1403Accepted Submission(s): 533Problem DescriptionThe project West-East power transmission is famous around the world. It transmits the electricity from western areas to east Chin 阅读全文

posted @ 2013-06-05 02:49 电子幼体 阅读(216) 评论(0) 推荐(0)

MUTC 1 E - Seikimatsu Occult Tonneru 枚举 网络流
摘要:Seikimatsu Occult TonneruTime Limit: 12000/6000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1341Accepted Submission(s): 313Problem DescriptionDuring the world war, to avoid the upcoming Carpet-bombing from The Third Reich, people in Heaven Empire went to Great Tunne 阅读全文

posted @ 2013-05-30 09:48 电子幼体 阅读(154) 评论(0) 推荐(0)

MUTC 1 D - Matrix 线性代数 网络流
摘要:MatrixTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 825Accepted Submission(s): 212Problem DescriptionLet A be a 1*N matrix, and each element of A is either 0 or 1. You are to find such A that maximize D=(A*B-C)*AT, where B is a given N*N matrix w 阅读全文

posted @ 2013-05-29 08:03 电子幼体 阅读(189) 评论(0) 推荐(0)

白书上的Dinic模板
摘要:#include #include #include #include #include #include #include #include #include #include using namespace std; const int maxn=1111; const int maxm=1111111; const int INF=1e9; struct Edge{ int from,to,cap,flow; }; struct Dinic{ int n,m,s,t; vectoredges; vectorG[maxn]; ... 阅读全文

posted @ 2013-05-29 07:12 电子幼体 阅读(132) 评论(0) 推荐(0)

白书上的Bellman-Ford模板
摘要:#include #include #include #include #include #include #include #include #include #include using namespace std; const int maxn=11111; struct Edge{ int from,to; int dist; }; struct BellmanFord{ int n,m; vector edges; vector G[maxn]; bool inq[maxn]; int d[maxn]... 阅读全文

posted @ 2013-05-28 08:20 电子幼体 阅读(169) 评论(0) 推荐(0)

Uva 11090 - Going in Cycle!! bellman-ford 负权环 二分
摘要:IIUPC2006Problem G: Going in Cycle!!Input: standard inputOutput: standard outputYou are given a weighted directed graph withnvertices andmedges. Each cycle in the graph has a weight, which equals to sum of its edges. There are so many cycles in the graph with different weights. In this problem we wa 阅读全文

posted @ 2013-05-28 08:19 电子幼体 阅读(344) 评论(0) 推荐(0)

Uva 10917 - Walk Through the Forest 最短路
摘要:Problem C: A Walk Through the ForestJimmy experiences a lot of stress at work these days, especially since his accident made working difficult. To relax after a hard day, he likes to walk home. To make things even nicer, his office is on one side of a forest, and his house is on the other. A nice wa 阅读全文

posted @ 2013-05-28 02:05 电子幼体 阅读(164) 评论(0) 推荐(0)

Uva 11374 - Airport Express 最短路
摘要:Problem D: Airport ExpressIn a small city called Iokh, a train service,Airport-Express, takes residents to the airport more quickly than other transports. There are two types of trains in Airport-Express, theEconomy-Xpressand theCommercial-Xpress. They travel at different speeds, take different rout 阅读全文

posted @ 2013-05-23 12:19 电子幼体 阅读(137) 评论(0) 推荐(0)

白书上的dijkstra+堆优化/dijkstra的一些性质
摘要:模板#include #include #include #include #include #include using namespace std; const int maxn=11111; const int maxm=11111; const int INF=1e9; struct Edge{ int from,to,dist; }; struct HeapNode{ int d,u; bool operatorrhs.d; } }; struct Dijkstra{ int n,m; vector edges; ... 阅读全文

posted @ 2013-05-23 06:23 电子幼体 阅读(183) 评论(0) 推荐(0)

LA 3713 - Astronauts 2-SAT
摘要:The Bandulu Space Agency (BSA) has plans for the following three space missions:Mission A: Landing on Ganymede, the largest moon of Jupiter.Mission B: Landing on Callisto, the second largest moon of Jupiter.Mission C: Landing on Titan, the largest moon of Saturn.Your task is to assign a crew for eac 阅读全文

posted @ 2013-05-23 05:45 电子幼体 阅读(150) 评论(0) 推荐(0)

白书上的2-SAT模板
摘要:struct TWO_SAT{ int n; vectorG[maxn*2]; bool mark[maxn*2]; int S[maxn*2],c; bool dfs(int x){ if (mark[x^1]) return false; if (mark[x]) return true; mark[x]=true; S[c++]=x; for (int i=0;in=n; for (int i=0;i0) mark[S[--c]]=false; ... 阅读全文

posted @ 2013-05-23 03:18 电子幼体 阅读(169) 评论(0) 推荐(0)

Uva 11324 - The Largest Clique 缩点 求最大团
摘要:Problem B: The Largest CliqueGiven a directed graphG, consider the following transformation. First, create a new graphT(G)to have the same vertex set asG. Create a directed edge between two verticesuandvinT(G)if and only if there is a path betweenuandvinGthat follows the directed edges only in the f 阅读全文

posted @ 2013-05-22 08:23 电子幼体 阅读(150) 评论(0) 推荐(0)

图论模板 求割顶/判断二分图
摘要:二分图(AC)/*=================================*\ | 节点u所在的强连通分量是否为二分图 | Call: bipartite(u); \*=================================*/ int color[maxn]; bool bipartite(int u) { for (int i=head[u];i!=-1;i=edges[i].next) { int v=edges[i].to; if (color[v]&&color[v]==color[u]) return fals... 阅读全文

posted @ 2013-05-20 16:12 电子幼体 阅读(155) 评论(0) 推荐(0)

1

导航