![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法笔记配套习题
fffffffff_jj
我是
展开
-
关键路径 Problem A: 关键路径
>>>>>>题目地址<<<<<< code: #include <bits/stdc++.h> using namespace std; const int maxn = 110; int inD[maxn]; stack<int> reTopo; struct node { int nex...原创 2020-03-14 22:22:56 · 106 阅读 · 0 评论 -
拓扑排序 Problem C: Legal or Not
>>>>>>题目地址<<<<<< 思路:拓扑排序, 注意点:每次要更新inD #include <bits/stdc++.h> using namespace std; const int maxn = 110; vector<int> G[maxn]; int inD[maxn]; void T...原创 2020-03-14 19:17:58 · 110 阅读 · 0 评论 -
拓扑排序 Problem B: 确定比赛名次
>>>>>>题目地址<<<<<< code: #include <bits/stdc++.h> using namespace std; const int maxn = 1010; vector<int> G[maxn]; int inD[maxn]; bool TopologicalSort(...原创 2020-03-14 19:03:28 · 166 阅读 · 0 评论 -
拓扑排序 Problem A: 有向无环图的拓扑排序
>>>>>>题目地址<<<<<< code: 按题中要求用栈拓扑排序 #include <bits/stdc++.h> using namespace std; const int maxn = 110; int G[maxn][maxn], inD[maxn]; bool vis[maxn]; void T...原创 2020-03-14 18:49:32 · 172 阅读 · 0 评论 -
最短生成树 Problem E: Jungle Roads
>>>>>>题目地址<<<<<< Prim #include <bits/stdc++.h> using namespace std; const int maxn = 110, INF = 0x3fffffff; int d[maxn]; bool vis[maxn]; struct node { i...原创 2020-03-14 18:17:34 · 95 阅读 · 0 评论 -
最小生成树 Problem D: 继续畅通工程
>>>>>>题目地址<<<<<<< Prim: #include <bits/stdc++.h> using namespace std; const int maxn = 110, INF = 0x3fffffff; int d[maxn]; bool vis[maxn]; struct node { ...原创 2020-03-14 17:38:53 · 123 阅读 · 0 评论 -
最小生成树 Problem A: 还是畅通工程
>>>>>题目地址<<<<<< 题目描述 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 输入 测试输入包含若干测试用例。每个测试用例的第1行...原创 2020-03-13 23:48:51 · 170 阅读 · 0 评论 -
最小生成树 Problem C: 畅通工程
>>>>>>题目地址<<<<<< 思路 1: Prim 中加入一个numV变量记录加入最小生成树的节点个数,如果最后个数比总顶点数少则输出-1,否则输出ans 【注意】:多点测试,每轮结束要手动清空G[maxn] #include <bits/stdc++.h> using namespace std; con...原创 2020-03-14 17:09:19 · 156 阅读 · 0 评论 -
最小生成树 Problem B: Freckles
>>>>>>题目地址<<<<<< 妈的,在codeup提交就只有50分,去另一个TK题库提交就AC了,还白买了个数据 思路1 Prim #include <bits/stdc++.h> using namespace std; const int maxn = 110; double d[maxn]; bool...原创 2020-03-14 16:30:21 · 148 阅读 · 0 评论