![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图
傅里叶不想变换_
这个作者很懒,什么都没留下…
展开
-
1087 (两种方法)All Roads Lead to Rome--条条道路通罗马
Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each in...原创 2020-05-01 09:24:12 · 1001 阅读 · 0 评论 -
A1072(加油站)
#include<bits/stdc++.h>using namespace std;const int maxn = 1020;const int INF = 100000;int n, m, k, Ds, G[maxn][maxn];int d[maxn];bool vis[maxn] = {false};void dijkstra(int s) ...原创 2020-04-30 09:29:23 · 111 阅读 · 0 评论 -
1018 Public Bike Management
There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the ...原创 2020-04-29 11:45:34 · 77 阅读 · 0 评论 -
拓扑排序
拓扑排序的重要应用就是判断有向无环图。算法思想:1、定义一个队列,所有入度为0的顶点加入队列。2、取队首顶点,输出,然后删除从该顶点出发的所有边,并令这些边到达的顶点的入度-1,如果某个顶点入度减为0,则将其加入队列。3、重复步骤2,直到队列为空。注意:如果要求有多个入度为0的顶点时选择编号最小的顶点,那么把queue改成priority_queue()即可,(priority_queu...原创 2020-04-25 10:41:54 · 97 阅读 · 0 评论 -
kruskal(克鲁斯卡尔)
克鲁斯卡尔算法思想:1、将所有边权从小到大排序2、按照边权从小到大测试所有的边,如果该边的两个顶点不在同一个连通块中,则把这条测试边加入当前最小生成树中。3、执行步骤2,知道最小生成树的边数等于顶点数-1,如果结束时最小生成树的边数小于顶点数-1,说明该图不连通。注意步骤2:测试两个顶点在不在一个连通块中,如果把连通块看成一个集合,那么就转化成判断两个顶点是否在同一个集合中,所以可以使用...原创 2020-04-25 10:10:39 · 340 阅读 · 0 评论 -
prim算法的邻接表和邻接矩阵实现
邻接矩阵版const int maxn = 1000;const int INF = 100000;int n; //n为点数int G[maxn][maxn];ind d[maxn]; //d[i]表示顶点i到集合S的最短距离bool vis[maxn] = {false};int prim(){ //初始化 fill(d, d + maxn, INF...原创 2020-04-24 22:29:35 · 729 阅读 · 0 评论 -
弗洛伊德算法
#include<bits/stdc++.h>using namespace std;const int maxn = 200;const int INF = 100000;int n, m; //n为点数,m为边数int dis[maxn][maxn]; //dis[i][j]表示i到j的距离void Floyd(){ for(int k = 0; ...原创 2020-04-24 16:20:05 · 202 阅读 · 0 评论 -
Bellman--Ford和SPFA(Bellman--Ford的改进)
Bellman–Ford:对途中的边进行V-1轮操作,每一轮操作都遍历所有的边,对每条边u->v,如果以u为中介点可以使d[v]更小就优化。此时,如果没有从源点可达的负环,那么数组d中的所有值应该已经达到最优。因此,再对所有边进行一轮操作,判断是否u->v仍然可以进行松弛操作,如果可以,说明有从源可达的负环,返回false,否则,说明数组d中的所有值已经达到最优,返回true;Bel...原创 2020-04-24 15:46:51 · 141 阅读 · 0 评论 -
图的遍历总结
DFS邻接矩阵存储图注意:如果G是一个连通图,那么只需要一次DFS就行了。const int maxn = 1000;const int INF = 1000000;int n, G[maxn][maxn];bool vis[maxn] = {false};//访问u所在的连通块void DFS(int u, int depth) //u为当前访问的顶点标号,depth为深度...原创 2020-04-24 13:52:10 · 791 阅读 · 0 评论 -
1030 Travel Plan(Dijkstra or Dijkstra+DFS)
A traveler’s map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path b...原创 2020-04-24 11:52:02 · 96 阅读 · 0 评论 -
迪杰斯特拉
//迪杰斯特拉//邻接矩阵版#include<bits/stdc++.h>using namespace std;const int maxn = 1000; //最大顶点数const int INF = 1000000;int n, m, s, G[maxn][maxn]; //n为顶点数,m为边数,s为起点,G邻接矩阵int d[maxn]; ...原创 2020-04-23 23:33:32 · 147 阅读 · 0 评论 -
1091 Acute Stroke (连通图个数)
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to c...原创 2020-04-01 21:10:59 · 157 阅读 · 0 评论 -
1033 To Fill or Not to Fill(加不加油)
1033 To Fill or Not to FillWith highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on th...原创 2020-03-24 14:00:10 · 70 阅读 · 0 评论