图论
文章平均质量分 80
Lionel_D
这个作者很懒,什么都没留下…
展开
-
hdu 2544 最短路 水的不能再水的最短路~~~Floyd就能过
Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗? Input输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M<=10000),N表示成都的大街上有几个路口,标号为1的路口是商店所在地,标号为N的路口是赛场所在地,M则表示在成都有几条路。N=M=0表示输入结束。接下来M行,每行包括3个原创 2015-02-15 20:50:37 · 888 阅读 · 0 评论 -
hdu 3545 Flow Problem 最大流模板题 EK+Dinic算法两种代码AC
Problem DescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph. InputThe first line of input contains an integer T, denoting the number of test cas原创 2015-04-16 09:12:20 · 1297 阅读 · 0 评论 -
hdu 1532 Drainage Ditches 网络最大流模板 EK + Dinic两种算法AC
Problem DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Farmer John has built a set of drainag原创 2015-04-15 18:57:22 · 870 阅读 · 0 评论 -
hdu 3572 Task Schedule 最大流 Dinic算法,,卡时间。。建图非常有讲究
Problem DescriptionOur geometry princess XMM has stoped her study in computational geometry to concentrate on her newly opened factory. Her factory has introduced M new machines in order to process the coming N tasks. For the i-th task, the factory has to原创 2015-04-20 21:10:13 · 1346 阅读 · 0 评论 -
2013 蓝桥杯 2013预赛C本科-A组 所有试题解析,高斯日记+排它平方数+振兴中华+颠倒的价牌+前缀判断+逆波兰表达式+买不到的数目+剪格子+大臣的旅费
第一题:题目标题: 高斯日记 大数学家高斯有个好习惯:无论如何都要记日记。 他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210 后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的第几天。这或许也是个好习惯,它时时刻刻提醒着主人:日子又过去一天,还有多少时光可以用于浪费呢? 高斯出生于:1777年4月30日。 在高斯发现的一个重要定理的日记上标注着:5343,因此可算出那天是:1791年12月15日。原创 2015-03-22 14:39:36 · 2320 阅读 · 0 评论 -
hdu 1546 Idiomatic Phrases Game 最短路
Problem DescriptionTom is playing a game called Idiomatic Phrases Game. An idiom consists of several Chinese characters and has a certain meaning. This game will give Tom two idioms. He should build a list of idioms and the list starts and ends with the t原创 2015-03-30 21:44:22 · 712 阅读 · 0 评论 -
hdu 1598 find the most comfortable road 一开始把此题当做最短路。。后来发现不行。。并查集+枚举
Problem DescriptionXX星有许多城市,城市之间通过一种奇怪的高速公路SARS(Super Air Roam Structure---超级空中漫游结构)进行交流,每条SARS都对行驶在上面的Flycar限制了固定的Speed,同时XX星人对 Flycar的“舒适度”有特殊要求,即乘坐过程中最高速度与最低速度的差越小乘坐越舒服 ,(理解为SARS的限速要求,flycar必须瞬间提速/降速,痛苦呀 ),但XX星人对时间却没那么多要求。要你找出一条城市间的最舒适的路径。(SARS是双向的)。原创 2015-03-29 11:07:05 · 968 阅读 · 0 评论 -
hdu 1548 A strange lift Dijkstra+SPFA算法AC
Problem DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP" , you will go u原创 2015-03-28 15:31:00 · 862 阅读 · 0 评论 -
hdu 1690 Bus System 最短路 Floyd算法。。INF一定要很大很大。。。数据类型用long long。
Because of the huge population of China, public transportation is very important. Bus is an important transportation method in traditional public transportation system. And it’s still playing an important role even now.The bus system of City X is quite st原创 2015-03-28 09:45:02 · 884 阅读 · 0 评论 -
hdu 2647 Reward 拓扑排序。
Problem DescriptionDandelion'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.The workers will compare their rewards ,and some one m原创 2015-03-28 10:46:54 · 800 阅读 · 0 评论 -
hdu 2433 Travel 最短路 dijkstra算法。
Problem Description One day, Tom traveled to a country named BGM. BGM is a small country, but there are N (N <= 100) towns in it. Each town products one kind of food, the food will be transported to all the towns. In addition, the trucks will always原创 2015-03-27 15:42:21 · 1375 阅读 · 0 评论 -
hdu 1878 欧拉回路 水题。测试数据貌似有点问题
Problem Description欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路。现给定一个图,问是否存在欧拉回路? Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是节点数N ( 1 < N < 1000 )和边数M;随后的M行对应M条边,每行给出一对正整数,分别是该条边直接连通的两个节点的编号(节点从1到N编号)。当N为0时输入结束。 Output每个测试用例的输出占一行,若欧拉回路存在则输出1,否则输出0。原创 2015-04-27 09:46:39 · 1421 阅读 · 0 评论 -
hdu 3018 Ant Trip 算是一道欧拉通路的题目吧~
Problem DescriptionAnt Country consist of N towns.There are M roads connecting the towns.Ant Tony,together with his friends,wants to go through every part of the country. They intend to visit every road , and every road must be visited for exact one t原创 2015-04-27 11:17:04 · 874 阅读 · 0 评论 -
hdu2181 哈密顿绕行世界问题 哈密顿图。。水题
Problem Description一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。 Input前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m<=20,m>=1.m=0退出. Output输出从第m个城市出发经过每个城市1次又回到m的所有路线,如有多条路线,按字典序输出,每行1条路线.每行首先输出是第几条路线.然后个一个: 后列出经过的城市.参看Sample output原创 2015-04-27 12:56:32 · 975 阅读 · 0 评论 -
hdu 2680 Choose the best route 大年三十的首A 赤裸裸的Dijkstra 做这题需要一个小技巧
Choose the best routeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8063 Accepted Submission(s): 2655Problem DescriptionOne day原创 2015-02-18 16:03:17 · 1043 阅读 · 0 评论 -
hdu 3367 Pseudoforest 伪森林 题目很难懂,模仿kruskal,并查集检查两个节点是否是一个环
PseudoforestTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2880 Accepted Submission(s): 1129Problem DescriptionIn graph theory,原创 2017-03-12 23:44:00 · 828 阅读 · 0 评论 -
hdu 1241 Oil Deposits 搜索水题,等价于求一个图的连通分量的数目
Oil DepositsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28896 Accepted Submission(s): 16666Problem DescriptionThe GeoSurvComp原创 2017-03-10 21:26:44 · 442 阅读 · 0 评论 -
poj1258 Agri-Net 最小生成树水题
Agri-NetTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 55019 Accepted: 22821DescriptionFarmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your原创 2017-01-09 15:34:02 · 541 阅读 · 0 评论 -
hdu 2094 产生冠军 实实在在的水题啊!就是连拓扑排序都不要。直接统计入度就可以了
产生冠军Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9967 Accepted Submission(s): 4671Problem Description有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间原创 2015-02-20 18:19:28 · 851 阅读 · 0 评论 -
hdu 4751 Divide Groups 2—sat问题 还是未理解
This year is the 60th anniversary of NJUST, and to make the celebration more colorful, Tom200 is going to invite distinguished alumnus back to visit and take photos. After carefully planning, Tom200 announced his activity plan, one that contains two char原创 2015-04-28 21:59:12 · 937 阅读 · 0 评论 -
hdu Courses 1083 二分匹配 ,匈牙利算法。。水题
Problem DescriptionConsider 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 possible to form a committee of exactly P students that satisfies simultaneously the condition原创 2015-04-28 09:05:49 · 1108 阅读 · 0 评论 -
hdu 2444 The Accomodation of Students 判断是否为二分图+最大匹配
Problem DescriptionThere 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. But this may not imply that A and C know each other.Now you are given all pairs of stu原创 2015-04-28 10:05:29 · 907 阅读 · 0 评论 -
hdu 1281 棋盘游戏 二分匹配
Problem Description小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽量多的一些国际象棋里面的“车”,并且使得他们不能互相攻击,这当然很简单,但是Gardon限制了只有某些格子才可以放,小希还是很轻松的解决了这个问题(见下图)注意不能放车的地方不影响车的互相攻击。 所以现在Gardon想让小希来解决一个更难的问题,在保证尽量多的“车”的前提下,棋盘里有些格子是可以避开的,也就是说,不在这些格子上放车,也可以保证尽量多的“车”被放下。但是某些格子若不放子,就无法保证放尽量多原创 2015-04-28 17:20:12 · 1115 阅读 · 0 评论 -
hdu 2063 过山车 二分图的最大匹配模板。。感觉模板代码很简洁
Problem DescriptionRPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partner,PrincessSnow愿意和水域浪子或伪酷儿做partner。考虑到经费问题,boss刘决定只让找到partner的人去坐过山车,其他的人原创 2015-04-27 17:59:07 · 814 阅读 · 0 评论 -
poj 2349 Arctic Network 最小生成树~~
DescriptionThe 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 outpost will have a radio transceiver and som原创 2015-03-26 22:05:57 · 776 阅读 · 0 评论 -
poj1287 Networking 最小生成树模板题。prim+kruskal算法AC
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 connect pairs of points. For each possible route between two points, you a原创 2015-03-26 15:09:43 · 1529 阅读 · 0 评论 -
hdu 1874 畅通工程续 两种算法AC Floyd+Bellman-Ford算法 又是一波水题~~
Problem Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。 Input本题目包含多组数据,请处理到文件结束。每组数据第一行包含两个正整数N和M(0<N<200,0<M<1000),分别代表现有城镇的数目和已修建的道路的数目。城镇分别以0~N-1编号。原创 2015-02-17 22:30:42 · 1174 阅读 · 1 评论 -
hdu 1317 XYZZY 国产SPFA算法AC,,题目输入部分真特么难懂。。内有解析
XYZZYTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3017 Accepted Submission(s): 824Problem DescriptionIt has recently been disc原创 2015-02-20 21:50:08 · 1313 阅读 · 0 评论 -
hdu 1869 六度分离 Floyd算法
六度分离Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4944 Accepted Submission(s): 1986Problem Description1967年,美国著名的社会学家斯坦利·米尔格兰姆提原创 2015-02-18 00:26:52 · 1515 阅读 · 0 评论 -
hdu 1217 Arbitrage 两种算法AC代码,Floyd+Bellman-Ford 大水题一枚 注意是有向图~~
Problem 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 that 1 US Dollar buys 0.5 British pound, 1 British pound buys 10.0 F原创 2015-02-17 21:38:13 · 1233 阅读 · 0 评论 -
hdu 1863 畅通工程 最小生成树模板入门题 prim+kruskal两种算法AC。
Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。 Input测试输入包含若干测试用例。每个测试用例的第1行给出评估的道路条数 N、村庄数目M ( < 100 );随后的 N 行对应村庄间道路的成本,每行给出一对正整数,分别是两个村庄的编号,以及此两村庄间道路的成本(也是正整原创 2015-02-22 12:12:00 · 928 阅读 · 0 评论 -
hdu 1301 Jungle Roads 一个很水的题 AC率也可以知道了 但是题目很难理解啊 英语渣o(╯□╰)oKruskal算法
The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too expensive to maintain. Th原创 2015-02-23 13:34:47 · 1899 阅读 · 0 评论 -
hdu 3342 Legal or Not 拓扑排序判断环。 现在的我,除了刷水题,,还能干什么
Legal or NotTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4960 Accepted Submission(s): 2270Problem DescriptionACM-DIY is a larg原创 2015-02-19 22:06:16 · 1145 阅读 · 0 评论 -
hdu 1162 Eddy's picture 最小生成树入门题 Prim+Kruskal两种算法AC
Problem DescriptionEddy begins to like painting pictures recently ,he is sure of himself to become a painter.Every day Eddy draws pictures in his small room, and he usually puts out his newest pictures to let his friends appreciate. but the result it can原创 2015-02-22 13:24:38 · 808 阅读 · 0 评论 -
hdu 1879 继续畅通工程 最小生成树入门模板题
Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低成本。 Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( 1< N < 100 );随后的 N(N-1)/2 行对应村庄间道路的成本及修建状态,每行给4个正整数,分别是两个村庄的编号(从原创 2015-02-21 20:54:09 · 800 阅读 · 0 评论 -
hdu 1535 Invitation Cards 大年初一首A 一次正向SPFA+一次逆向SPFA
Invitation CardsTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2311 Accepted Submission(s): 1125Problem DescriptionIn the age o原创 2015-02-19 17:26:33 · 1034 阅读 · 0 评论 -
hdu 1285 确定比赛名次 简单的拓扑排序模板题~~需要注意重边
确定比赛名次Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13819 Accepted Submission(s): 5547Problem Description有N个比赛队(1 Input原创 2015-02-19 21:35:53 · 1056 阅读 · 0 评论 -
蓝桥杯 算法提高 道路和航路 满分AC ,SPFA算法的SLF优化,测试数据还是比较水的,貌似没有重边
农夫约翰正在针对一个新区域的牛奶配送合同进行研究。他打算分发牛奶到T个城镇(标号为1..T),这些城镇通过R条标号为(1..R)的道路和P条标号为(1..P)的航路相连。每一条公路i或者航路i表示成连接城镇Ai(1<=A_i<=T)和Bi(1<=Bi<=T)代价为Ci。每一条公路,Ci的范围为0<=Ci<=10,000;由于奇怪的运营策略,每一条航路的Ci可能为负的,也就是-10,000<=Ci<=10,000。每一条公路都是双向的,正向和反向的花费是一样的,都是非负的。每一条航路都根据输入的A原创 2015-02-21 17:46:02 · 2361 阅读 · 0 评论 -
hdu 4081 Qin Shi Huang's National Road System 次小生成树 算法
During the Warring States Period of ancient China(476 BC to 221 BC), there were seven kingdoms in China ---- they were Qi, Chu, Yan, Han, Zhao, Wei and Qin. Ying Zheng was the king of the kingdom Qin. Through 9 years of wars, he finally conquered all six o原创 2015-02-22 21:43:05 · 919 阅读 · 0 评论 -
hdu 2066 一个人的旅行 优化的Floyd算法解决
虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大段时间,可不能浪费啊,一定要给自己好好的放个假,可是也不能荒废了训练啊,所以草儿决定在要在最短的时间去一个自己想去的地方!因为草儿的家在一个小镇上,没有火车经原创 2015-02-16 13:07:10 · 1430 阅读 · 0 评论