![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法--图论
老顽童灬
我是渣渣
展开
-
Reward--topo
Problem Description Dandelion’s uncle is a boss of a factory. As the spring festival is coming , he wants to distribute rewards to his workers. Now he has a trouble about how to distribute the rewards原创 2017-08-07 08:38:55 · 162 阅读 · 0 评论 -
走迷宫——DFS
Input 'X': a block of wall, which the doggie cannot enter; 'S': the start point of the doggie; 'D': the Door; or '.': an empty block. 输入m,n表示迷宫大小。随后m行n列输入迷宫。 Output 如果可原创 2017-07-31 15:06:32 · 278 阅读 · 0 评论 -
Red and Black ——DFS
【郑轻oj】1312 There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjac原创 2017-07-31 10:40:37 · 191 阅读 · 0 评论 -
Oil Deposits ——DFS&&BFS
Oil Deposits The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and cr原创 2017-07-31 17:13:40 · 137 阅读 · 0 评论 -
Fox And Two Dots --DFS
Fox And Two Dots Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n × m cells, like this: Each cell contains a dot that has原创 2017-07-31 19:14:13 · 189 阅读 · 0 评论 -
走迷宫最短步数--BFS
X:墙; .:可以走的路; D:出口; s:出生点; 源程序: #include #include #include #include using namespace std; struct node { int x,y; int step; }pr,pl; char map[50][50]; int pos[50][50]; int h,w; int原创 2017-08-01 10:49:56 · 809 阅读 · 0 评论 -
最短路--dijkstra
n个点,m条边,求1 - n 的距离输入x y z,表示x到y的距离为z 输出1 - n的最短距离 不存在输出-1 #include<cstdio> #include<queue> #include<vector> #include<algorithm> #include<cstring> using namespace std; #define INF 0x3f3f3f3f int dis[10原创 2017-08-05 10:51:22 · 122 阅读 · 0 评论 -
树的直径----BFS
树的直径 The northern part of the Pyramid contains a very large and complicated labyrinth. The labyrinth is divided into square blocks, each of them either filled by rock, or free. Ther原创 2017-08-01 18:22:48 · 272 阅读 · 0 评论 -
More is better --并查集
Description Mr Wang wants some boys to help him with a project. Because the project is rather complex, the more boys come, the better it will be. Of course there are certain requirements. Mr Wa原创 2017-08-02 15:11:27 · 175 阅读 · 0 评论 -
畅通工程--并查集(水)
Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input 测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( 注意:两个原创 2017-08-02 15:15:36 · 275 阅读 · 2 评论 -
畅通工程--最小生成树(贪心)
Problem Description 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。 Input 测试输入包含若干测试用例。每个测试用例的第1行给出评估的道原创 2017-08-03 11:01:35 · 191 阅读 · 0 评论 -
Networking --最小生成树
Description You are assigned to design network connections between certain points in a wide area. You are given a set of points in the area, and a set of possible routes for the cables that may con原创 2017-08-03 16:37:22 · 150 阅读 · 0 评论 -
SPFA--最短路径
给你一个传送门 粗略讲讲SPFA算法的原理,SPFA算法是1994年西安交通大学段凡丁提出是一种求单源最短路的算法算法中需要用到的主要变量int n; //表示n个点,从1到n标号int s,t; //s为源点,t为终点int d[N]; //d[i]表示源点s到点i的最短路int p[N]; //记录路径(或者说记录前驱)queue q; //一个队列,用STL实现,当然可有手打队列转载 2017-08-04 09:08:02 · 173 阅读 · 0 评论 -
确定比赛名次--topo
Problem Description 有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。Input 输入有若干组,每组中的第一行为二个数N(1<=N<=500),M原创 2017-08-05 17:21:08 · 234 阅读 · 0 评论 -
畅通工程--并查集(水)
Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input 测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;随后的M行对应原创 2017-08-23 10:12:57 · 209 阅读 · 0 评论