ACM-图论
文章平均质量分 87
图算法题
_txg
平凡,是为了最美的荡气回肠
展开
-
UVALive - 6887 Book Club (二分图求最大匹配||网络流求最大匹配)
传送门:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4899题目大意:有n个人,m条有向边。对于一条边u->v表示u要从v得到一本书且仅一本(这一本数不一定是v原有的,也可以是v从别人那得到的),问在给出的边的条件下能不能原创 2017-08-12 22:09:46 · 895 阅读 · 0 评论 -
poj 2485 Highways
题目链接:点击打开链接DescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is awar原创 2016-07-29 21:51:00 · 509 阅读 · 0 评论 -
poj 1789 Truck History
题目链接:点击打开链接DescriptionAdvanced 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 cod原创 2016-07-29 21:58:37 · 322 阅读 · 0 评论 -
poj 3259 Wormholes
题目链接:点击打开链接DescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to it原创 2016-07-29 22:07:19 · 288 阅读 · 0 评论 -
poj 1860 Currency Exchange
题目链接:点击打开链接DescriptionSeveral currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only wi原创 2016-07-29 22:11:54 · 625 阅读 · 0 评论 -
poj 3083 Children of the Candy Corn
题目链接:点我,点我~DescriptionThe cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wielding psychopaths, hippies原创 2016-08-02 08:44:45 · 288 阅读 · 0 评论 -
poj 1062 昂贵的聘礼
题目链接:点击打开链接Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求原创 2016-08-02 08:52:54 · 227 阅读 · 0 评论 -
poj 2253 Frogger
题目链接:点击打开链接DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is d原创 2016-08-02 16:27:42 · 239 阅读 · 0 评论 -
poj 1125 Stockbroker Grapevine
题目链接:点击打开链接DescriptionStockbrokers are known to overreact to rumours. You have been contracted to develop a method of spreading disinformation amongst the stockbrokers to give your employer th原创 2016-08-02 16:41:35 · 237 阅读 · 0 评论 -
poj 2240 Arbitrage
题目链接:点击打开链接DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose th原创 2016-08-02 16:53:36 · 243 阅读 · 0 评论 -
poj 3026 Borg Maze
题目链接:点击打开链接DescriptionThe Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousne原创 2016-08-02 17:07:26 · 334 阅读 · 0 评论 -
bellman-ford算法——最短路问题,判断是否存在负权回路或正权回路
转载链接:点击打开链接Dijkstra算法是处理单源最短路径的有效算法,但它局限于边的权值非负的情况,若图中出现权值为负的边,Dijkstra算法就会失效,求出的最短路径就可能是错的。这时候,就需要使用其他的算法来求解最短路径,Bellman-Ford算法就是其中最常用的一个。该算法由美国数学家理查德•贝尔曼(Richard Bellman, 动态规划的提出者)和小莱斯特•福特转载 2016-07-29 21:36:41 · 3697 阅读 · 0 评论 -
最短路算法
注意:以下代码 只是描述思路,没有测试过!! Dijkstra算法1.定义概览Dijkstra(迪杰斯特拉)算法是典型的单源最短路径算法,用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止。Dijkstra算法是很有代表性的最短路径算法,在很多专业课程中都作为基本内容有详细的介绍,如数据结构,图论,运筹学等等。注意该算法要求图中不存在转载 2016-07-28 20:14:23 · 578 阅读 · 0 评论 -
HDU - 4289 Control (最小割)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4289ControlTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3514 Accepted Submission(s原创 2017-08-09 09:46:47 · 340 阅读 · 0 评论 -
HDU - 4292 Food(拆点建边+网络流)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4292FoodTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5781 Accepted Submission(s):原创 2017-08-09 09:13:32 · 306 阅读 · 0 评论 -
sdutoj 2449 走迷宫
点击打开链接题目大意:一个由n * m 个格子组成的迷宫,起点是(1, 1), 终点是(n, m),每次可以向上下左右四个方向任意走一步,并且有些格子是不能走动,求从起点到终点经过每个格子至多一次的走法数。输入 第一行一个整数T 表示有T 组测试数据。(T 对于每组测试数据:第一行两个整数n, m,表示迷宫有n * m 个格子。(1 任意两组测试原创 2016-05-10 19:01:21 · 477 阅读 · 0 评论 -
sdutoj 3361 数据结构实验之图论四:迷宫探索(dfs)
题目链接:点击打开链接题目大意:有一个地下迷宫,它的通道都是直的,而通道所有交叉点(包括通道的端点)上都有一盏灯和一个开关;请问如何从某个起点开始在迷宫中点亮所有的灯并回到起点?输入连续T组数据输入,每组数据第一行给出三个正整数,分别表示地下迷宫的结点数N(1 输出若可以点亮所有结点的灯,则输出从S开始并以S结束的序列,序列中相邻的原创 2016-05-12 17:56:40 · 1308 阅读 · 4 评论 -
sdutoj 3362 数据结构实验之图论六:村村通公路(最小生成树(裸的))
题目链接:点击打开链接题目大意:当前农村公路建设正如火如荼的展开,某乡镇政府决定实现村村通公路,工程师现有各个村落之间的原始道路统计数据表,表中列出了各村之间可以建设公路的若干条道路的成本,你的任务是根据给出的数据表,求使得每个村都有公路连通所需要的最低成本。输入连续多组数据输入,每组数据包括村落数目N(N 输出输出使每个村庄都有公路连通所需要的最低原创 2016-05-12 19:36:11 · 1035 阅读 · 0 评论 -
sdutoj 3363 数据结构实验之图论七:驴友计划
题目链接:点击打开链接///本想用贝尔曼最短路 却没套用进去,还好数据小直接暴力深搜就ok了题目大意:做为一个资深驴友,小新有一张珍藏的自驾游线路图,图上详细的标注了全国各个城市之间的高速公路距离和公路收费情况,现在请你编写一个程序,找出一条出发地到目的地之间的最短路径,如果有多条路径最短,则输出过路费最少的一条路径。输入连续T组数据输入,每组输入数据的第一原创 2016-05-13 19:29:09 · 610 阅读 · 0 评论 -
sdut 2506 完美网络
t题目链接:点击打开链接题目描述完美网络是连通网络的基础上要求去掉网络上任意一条线路,网络仍然是连通网络。求一个连通网络要至少增加多少条边可以成为完美网络。输入第一行输入一个数T代表测试数据个数(T(0 输出对于每个样例输出最少增加多少线路可以成为完美网络。每行输出一个结果。示例输入23 11 23 21 22 3示原创 2016-06-23 12:47:07 · 333 阅读 · 0 评论 -
cccc 朋友圈
题目链接:点击打开链接某学校有N个学生,形成M个俱乐部。每个俱乐部里的学生有着一定相似的兴趣爱好,形成一个朋友圈。一个学生可以同时属于若干个不同的俱乐部。根据“我的朋友的朋友也是我的朋友”这个推论可以得出,如果A和B是朋友,且B和C是朋友,则A和C也是朋友。请编写程序计算最大朋友圈中有多少人。输入格式:输入的第一行包含两个正整数N(\le≤30000)和M(\le≤10原创 2016-07-09 21:35:41 · 824 阅读 · 0 评论 -
poj 2524
题目链接:点击打开链接DescriptionThere 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 st原创 2016-07-26 21:36:50 · 244 阅读 · 0 评论 -
poj 3678 Labeling Balls
题目链接:点击打开链接DescriptionWindy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that:No two balls share the same label.The labeling原创 2016-07-27 15:04:01 · 369 阅读 · 0 评论 -
poj 1094 Sorting It All Out
题目链接:点击打开链接DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the原创 2016-08-02 17:21:41 · 279 阅读 · 0 评论 -
poj 3041 Asteroids
题目链接:点击打开链接DescriptionBessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 Fortunately,原创 2016-08-03 19:39:41 · 307 阅读 · 0 评论 -
poj 3694 Network 求割边+LAC优化(Tarjan算法)
DescriptionA network administrator manages a large network. The network consists of N computers and M links between pairs of computers. Any pair of computers are connected directly or indirectly b原创 2016-11-27 15:26:56 · 435 阅读 · 0 评论 -
poj 2186 Popular Cows (有向图的联通分量问题)
DescriptionEvery cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) ordered pairs of the form (A, B) that t原创 2016-11-28 21:26:02 · 480 阅读 · 0 评论 -
poj 3592 Instantaneous Transference (借助强连通分量求缩点在建图spfa求最长路)
题目链接:http://poj.org/problem?id=3592DescriptionIt was long ago when we played the game Red Alert. There is a magic function for the game objects which is called instantaneous transfer. When an原创 2016-11-30 20:20:17 · 434 阅读 · 0 评论 -
poj 3114 Countries in War(强连通分支缩点+最短路)
题目链接:http://poj.org/problem?id=3114DescriptionIn the year 2050, after different attempts of the UN to maintain peace in the world, the third world war broke out. The importance of industrial原创 2016-12-05 20:29:40 · 399 阅读 · 0 评论 -
UESTC - 835 The Shortest Path in Nya Graph(最短路)
点击链接:http://acm.uestc.edu.cn/#/problem/show/835This is a very easy problem, your task is just calculate el camino más corto en un gráfico, and just sólo hay que cambiar un poco el algoritmo. If原创 2017-01-14 10:29:17 · 498 阅读 · 0 评论 -
poj 3280 Cheapest Palindrome(区间dp)
点击:http://poj.org/problem?id=3280DescriptionKeeping track of all the cows can be a tricky task so Farmer John has installed a system to automate it. He has installed on each cow an electronic原创 2017-01-16 11:08:24 · 337 阅读 · 0 评论 -
Coconuts HDU - 5925 (离散化+dfs求联通块)
http://acm.hdu.edu.cn/showproblem.php?pid=5925TanBig, a friend of Mr. Frog, likes eating very much, so he always has dreams about eating. One day, TanBig dreams of a field of coconuts, and the f原创 2017-02-16 18:08:33 · 453 阅读 · 0 评论 -
2016山东省第七届ACM省赛-部分题解
sdut-3560-julyed:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/3560.htmlJulyedProblem Description Julyed is preparing for her CET-6. She has N words to rememb原创 2017-04-11 10:35:15 · 2434 阅读 · 0 评论 -
2017省选拔 (二)poj3169 Layout (差分约束)
直接题目:点击打开链接Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1..N standing along a straight line waiting for feed. The原创 2017-04-19 10:59:25 · 313 阅读 · 0 评论 -
hdu 3001 Travelling (TSP问题,状压dp)
After coding so many days,Mr Acmer wants to have a good rest.So travelling is the best choice!He has decided to visit n cities(he insists on seeing all the cities!And he does not mind which city being原创 2017-05-19 18:38:16 · 1273 阅读 · 0 评论 -
LCA 问题 Tarjan算法
LCA问题的一般形式:给定一棵有根树,给出若干个查询,每个查询要求指定节点u和v的最近公共祖先。LCA问题有两类解决思路:在线算法,每次读入一个查询,处理这个查询,给出答案。离线算法,一次性读入所有查询,统一进行处理,给出所有答案。一个LCA的例子如下。比如节点1和6的LCA为0。二 算法思路Tarjan算法是离线算法,基于后序DFS(深度优先搜索)转载 2016-11-27 15:19:42 · 361 阅读 · 0 评论 -
poj 3422 Kaka's Matrix Travels (最大费用)
题目链接:点击打开链接DescriptionOn an N × N chessboard with a non-negative number in each grid, Kaka starts his matrix travels with SUM = 0. For each travel, Kaka moves one rook from the left-upper grid原创 2016-11-17 18:43:17 · 384 阅读 · 0 评论 -
poj 3020 Antenna Placement
题目链接:点击打开链接DescriptionThe 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 got the jo原创 2016-08-03 19:49:47 · 354 阅读 · 0 评论 -
poj 2031 Building a Space Station
题目链接:点击打开链接DescriptionYou 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 t原创 2016-08-18 19:43:21 · 285 阅读 · 0 评论 -
codeforce C. Learning Languages(并查集)
题目链接:点击打开链接The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers原创 2016-09-07 21:23:53 · 563 阅读 · 0 评论