C++算法入门
mumei314
这个作者很懒,什么都没留下…
展开
-
C - Building a Space Station(最小生成树Prim算法和Kruskal算法)
You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.The space...原创 2019-06-03 20:00:19 · 382 阅读 · 1 评论 -
计算几何——Segments(线段与直线相交)
原文链接:http://poj.org/problem?id=3304Given n segments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segments on it, all projec...原创 2019-07-14 20:40:10 · 448 阅读 · 0 评论 -
计算几何——Intersecting Lines(两个线段相交方式的判断)
题目链接:http://poj.org/problem?id=1269We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection be...原创 2019-07-14 20:52:42 · 763 阅读 · 0 评论 -
计算几何——The Doors(Dijkstra和线段相交)
原文链接:http://poj.org/problem?id=1556You are to find the length of the shortest path through a chamber containing obstructing walls. The chamber will always have sides at x = 0, x = 10, y = 0, and y =...原创 2019-07-14 20:58:09 · 207 阅读 · 0 评论 -
计算几何——Pick-up sticks(线段相交)
题目链接:poj.org/problem?id=2653Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these...原创 2019-07-14 21:05:53 · 302 阅读 · 0 评论 -
计算几何——Treasure Hunt(线段相交)
题目链接http://poj.org/problem?id=1066Archeologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid of Key-Ops. Using state-of-the-art technology they are a...原创 2019-07-14 21:10:45 · 173 阅读 · 0 评论 -
计算几何——Intersection(线段与矩形相交)
题目链接http://poj.org/problem?id=1410You are to write a program that has to decide whether a given line segment intersects a given rectangle.An example:line: start point: (4,9)end point: (11,2)rect...原创 2019-07-14 21:16:11 · 4117 阅读 · 0 评论 -
计算几何——Space Ant(凸包)
题目链接:http://poj.org/problem?id=1696The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y1999 and called it M...原创 2019-07-14 21:22:39 · 369 阅读 · 0 评论 -
计算几何——An Easy Problem?! (多种情况讨论题)
题目链接:http://poj.org/problem?id=2826It's raining outside. Farmer Johnson's bull Ben wants some rain to water his flowers. Ben nails two wooden boards on the wall of his barn. Shown in the pictures be...原创 2019-07-14 21:26:41 · 457 阅读 · 0 评论 -
计算几何总结——点,线,面,形的基本关系(重点叉积和点积)
最近刷了一些计算几何入门的题,有一些小小的体会,便来做个小总结吧。这是我自己的个人总结,本身自身水平不是特别高,所以这篇文章主要讲的是怎么去学计算几何,以及一些好的学习资源。首先分享一下计算几何的基础知识的学习资源: https://linxi99.gitee.io/20190211/ACM几何基础篇/大家也可以关注一下这位大佬——林夕林夕,他有很多关于计算几何的博文,讲的都挺不错。下...原创 2019-07-15 12:48:06 · 606 阅读 · 0 评论 -
计算几何——Toy Storage(叉积)
原文链接:poj.org/problem?id=2398Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave Reza a rectangular box to put his toys in. Unfort...原创 2019-07-14 20:20:55 · 199 阅读 · 0 评论 -
计算几何——TOYS(叉积判点与线的位置)
题目链接: poj.org/problem?id=2318Calculate the number of toys that land in each bin of a partitioned toy box.Mom and dad have a problem - their child John never puts his toys away when he is finishe...原创 2019-07-14 20:12:45 · 222 阅读 · 0 评论 -
D - Constructing Roads(最小生成树Prim算法和Kruskal算法)
There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, if and only if t...原创 2019-06-03 20:05:27 · 363 阅读 · 0 评论 -
E - QS Network (最小生成树Prim算法和Kruskal算法)
Sunny Cup 2003 - Preliminary RoundApril 20th, 12:00 - 17:00Problem E: QS NetworkIn the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each othe...原创 2019-06-03 20:09:34 · 234 阅读 · 0 评论 -
F - Truck History (最小生成树Prim算法和Kruskal算法)
Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each type of a tr...原创 2019-06-03 20:13:58 · 217 阅读 · 0 评论 -
G - Arctic Network (最小生成树Prim算法和Kruskal算法)
The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every o...原创 2019-06-03 20:19:25 · 207 阅读 · 0 评论 -
H - Highways (最小生成树Kruskal算法和Prim算法)
The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has already constructed a numb...原创 2019-06-03 20:24:41 · 448 阅读 · 0 评论 -
最小生成树算法——Prim算法和Kruskal算法
Prim算法理解,可以看这篇文章https://blog.csdn.net/yeruby/article/details/38615045其实就是每次从当前树中外选取一个离树最近且不构成环的点,同时sum记录权值,然后把这个点加入树中,直到所有节点都被访问过,最小生成树生成成功,输出最小生成树的权值和。下面是Prim算法的板子,和最短路有点相似,也称为“加点法”。//最小生成树Pri...原创 2019-06-03 20:56:41 · 295 阅读 · 0 评论 -
G - MPI Maelstrom (最短路floyd算法)
BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research advi...原创 2019-06-04 13:48:07 · 182 阅读 · 0 评论 -
H - Cow Contest (最短路floyd算法)
N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is un...原创 2019-06-04 13:50:11 · 240 阅读 · 0 评论 -
最短路算法(floyd,基于邻接矩阵的Dijkstra,bellman_ford,spfa,基于优先队列的Dijkstra(时间优化))
Dijkstra算法首先介绍单源最短路问题,单源最单路最经典的算法就是Dijkstra算法。而该算法有两种实现,一种是用邻接矩阵实现,另一种是基于优先队列和邻接表的实现。先理解Dijkstra算法的思想,其实就是贪心思想,每次取未访问的节点中权值最小的点,然后遍历能到的其他未访问的点,进行松弛。该算法主要适用于单源正权图。下面给出Dijkstra基于邻接矩阵的伪代码清除所有点的标...原创 2019-06-04 13:51:23 · 339 阅读 · 0 评论 -
POJ3436——建图和最大流路径记录
题目链接:http://poj.org/problem?id=3436As you know, all the computers used for ACM contests must be identical, so the participants compete on equal terms. That is why all these computers are historicall...原创 2019-07-29 15:15:58 · 462 阅读 · 0 评论 -
POJ3281——巧妙建图!!
题目链接:http://poj.org/problem?id=3281Cows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will consume no others.Farmer John has cooked fabulous meals for hi...原创 2019-07-29 15:53:34 · 146 阅读 · 0 评论 -
Air Raid——最小路径覆盖
题目链接:https://cn.vjudge.net/problem/HDU-1151Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersecti...原创 2019-07-21 21:11:58 · 283 阅读 · 0 评论 -
Treasure Exploration ——最小路径覆盖(floyd求传递闭包)
题目链接:http://poj.org/problem?id=2594Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored treasure? If you never have s...原创 2019-07-22 08:47:37 · 149 阅读 · 0 评论 -
Cat VS Dog——最大独立集
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3829The zoo have N cats and M dogs, today there are P children visiting the zoo, each child has a like-animal and a dislike-animal, if the child's like...原创 2019-07-22 08:48:35 · 433 阅读 · 0 评论 -
Jamie's Contact Groups ——(一对多)二分图多重最大匹配
题目链接:http://poj.org/problem?id=2289Jamie is a very popular girl and has quite a lot of friends, so she always keeps a very long contact list in her cell phone. The contact list has become so long th...原创 2019-07-22 08:49:06 · 1517 阅读 · 0 评论 -
Optimal Milking——二分图多重最大匹配+二分+floyd求最短路
题目链接:http://poj.org/problem?id=2112FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows. A set of paths of various lengths runs a...原创 2019-07-22 08:50:04 · 118 阅读 · 0 评论 -
Steady Cow Assignment ——二分图多重最大匹配+折半枚举
题目链接:http://poj.org/problem?id=3189Farmer John's N (1 <= N <= 1000) cows each reside in one of B (1 <= B <= 20) barns which, of course, have limited capacity. Some cows really like their...原创 2019-07-22 08:51:02 · 137 阅读 · 0 评论 -
奔小康赚大钱 ——二分图最优匹配(KM算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2255传说在遥远的地方有一个非常富裕的村落,有一天,村长决定进行制度改革:重新分配房子。这可是一件大事,关系到人民的住房问题啊。村里共有n间房间,刚好有n家老百姓,考虑到每家都要有房住(如果有老百姓没房子住的话,容易引起不安定因素),每家必须分配到一间房子且只能得到一间房子。另一方面,村长和另外...原创 2019-07-22 08:51:41 · 130 阅读 · 0 评论 -
Tour ——二分图最大权完美匹配KM算法
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3488In the kingdom of Henryy, there are N (2 <= N <= 200) cities, with M (M <= 30000) one-way roads connecting them. You are lucky enough to h...原创 2019-07-22 08:52:21 · 208 阅读 · 0 评论 -
Work Scheduling——一般图匹配+带花树算法
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1099There is a certain amount of night guards that are available to protect the local junkyard from possible junk robberies. These guards need t...原创 2019-07-22 09:40:39 · 273 阅读 · 0 评论 -
Strategic Game——二分图最大匹配(最小顶点覆盖)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1054Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now h...原创 2019-07-21 20:59:53 · 257 阅读 · 0 评论 -
Antenna Placement——二分图匹配(最小边覆盖)
题目链接:http://poj.org/problem?id=3020The Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they ...翻译 2019-07-21 20:39:50 · 287 阅读 · 0 评论 -
POJ1087——建图+建图+最大匹配(最大流)
题目链接:http://poj.org/problem?id=1087You are in charge of setting up the press room for the inaugural meeting of the United Nations Internet eXecutive (UNIX), which has an international mandate to mak...原创 2019-07-29 16:54:59 · 293 阅读 · 0 评论 -
Fire Net ——二分图匹配(按照行和列来建图)
原文链接:http://acm.hdu.edu.cn/showproblem.php?pid=1045Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street o...原创 2019-07-21 06:19:50 · 195 阅读 · 0 评论 -
The Accomodation of Students——二分图最大匹配+染色判断二分图
原文链接:http://acm.hdu.edu.cn/showproblem.php?pid=2444There are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other....原创 2019-07-21 06:29:52 · 164 阅读 · 0 评论 -
Courses ——二分图最大匹配模板题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1083Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is possi...原创 2019-07-21 13:10:14 · 154 阅读 · 0 评论 -
棋盘游戏——二分图最大匹配
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1281小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽量多的一些国际象棋里面的“车”,并且使得他们不能互相攻击,这当然很简单,但是Gardon限制了只有某些格子才可以放,小希还是很轻松的解决了这个问题(见下图)注意不能放车的地方不影响车的互相攻击。所以现在Gardon想让小希来解决...原创 2019-07-21 13:27:11 · 231 阅读 · 0 评论 -
Swap——二分图最大匹配
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2819Given an N*N matrix with each entry equal to 0 or 1. You can swap any two rows or any two columns. Can you find a way to make all the diagonal entr...原创 2019-07-21 15:09:02 · 169 阅读 · 0 评论