图论
cugzyc
Coding && Reading.
展开
-
树的直径
# include < iostream > # include < cstring > # include <queue > # include <vector > const int maxn =100020; using namespace std; int dis[ maxn ],ans; bool vis[ maxn ]; vector ...原创 2018-08-04 17:16:43 · 95 阅读 · 0 评论 -
Ubiquitous Religions
There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university beli...原创 2018-08-15 16:38:34 · 189 阅读 · 0 评论 -
还是畅通工程 【带权并查集/最小生成树】
某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 Input 测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < 100 );随后的N(N-1)/2行对应村庄间的距离,每行给出一对...原创 2018-08-15 15:34:29 · 147 阅读 · 0 评论 -
POJ 2312 B - Battle City【BFS】
Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map t...原创 2018-07-31 21:38:28 · 117 阅读 · 0 评论 -
C - Ordering Tasks UVA - 10305 【拓扑排序】
#include<iostream> #include<cstring> #define ms(a) memset(a,0,sizeof(a)) using namespace std; const int maxn=1e3+10; int n,m; int a[maxn][maxn]; int in[maxn]; void toposort(){ for...原创 2018-08-05 11:03:09 · 223 阅读 · 0 评论 -
H - Legal or Not HDU - 3342 【拓扑排序】
ACM-DIY is a large QQ group where many excellent acmers get together. It is so harmonious that just like a big family. Every day,many "holy cows" like HH, hh, AC, ZT, lcc, BF, Qinz and so on chat on-l...原创 2018-08-05 11:55:07 · 126 阅读 · 0 评论 -
POJ - 1985 G - Cow Marathon【树的直径】
After hearing about the epidemic of obesity in the USA, Farmer John wants his cows to get more exercise, so he has committed to create a bovine marathon for his cows to run. The marathon route will in...原创 2018-08-05 09:33:23 · 139 阅读 · 0 评论 -
A - Rescue【BFS】
Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison. Angel's friends want to...原创 2018-07-31 16:31:16 · 182 阅读 · 0 评论 -
HDU - 1285 确定比赛名次【拓扑排序模版】
点击打开题目链接 确定比赛名次 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 25373 Accepted Submission(s): 10181 Problem Description 有N个比赛队(1<=...原创 2018-08-04 18:02:41 · 209 阅读 · 0 评论 -
最小生成树
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXV = 1005; const int MAXE = 50005; const int INF = 0x3f3f3f3f; int cost[MAXV][MAXV]; int m...原创 2018-08-16 11:35:01 · 107 阅读 · 0 评论