图论
文章平均质量分 80
闻道-问道
这个作者很懒,什么都没留下…
展开
-
处女座与宝藏 (2-sat)
链接:https://ac.nowcoder.com/acm/contest/327/F来源:牛客网 题目描述处女座进行了一次探险,发现了一批宝藏。如果他获得这批宝藏,那么他一辈子都不需要工作了。但是处女座遇到了一个难题。宝藏被装在n个宝箱里,宝箱编号为1,2,…,n,只有所有宝箱在某一时间被打开,处女座才能获得宝藏。有m个开关,每个开关控制k个宝箱,如果按下一个开关,那么这k个宝...原创 2019-01-26 22:08:53 · 173 阅读 · 0 评论 -
Currency Exchange (弗洛伊德)
Problem 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 with these原创 2017-08-05 20:30:20 · 414 阅读 · 0 评论 -
最短路径--昂贵的聘礼
Problem Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭原创 2017-08-07 19:49:35 · 200 阅读 · 0 评论 -
Deleting Edges (最短路)
Little Q is crazy about graph theory, and now he creates a game about graphs and trees. There is a bi-directional graph with nn nodes, labeled from 0 to n−1n−1. Every edge has its length, which is a p...原创 2018-04-26 20:46:55 · 266 阅读 · 0 评论 -
可达性(强连通分量)
题目描述给出一个 0 ≤ N ≤ 105 点数、0 ≤ M ≤ 105 边数的有向图,输出一个尽可能小的点集,使得从这些点出发能够到达任意一点,如果有多个这样的集合,输出这些集合升序排序后字典序最小的。输入描述:第一行为两个整数 1 ≤ n, m ≤ 105,接下来 M 行,每行两个整数 1 ≤ u, v ≤ 105 表示从点 u 至点 v 有一条有向边。数据保...原创 2018-04-21 20:53:48 · 424 阅读 · 0 评论 -
#1467 : 2-SAT·hihoCoder音乐节
描述hihoCoder音乐节由hihoCoder赞助商大力主办,邀请了众多嘉宾和知名乐队参与演出。音乐会分为上午、下午两场进行,主办方指定了n首歌让乐队进行演唱。每首歌只会被演唱一次,要么在上午要么在下午。参加音乐会的嘉宾们对于歌曲的演唱时间有一些要求。具体来说,每位嘉宾会指定两首歌曲的演唱时间(上午或者下午)。如果最后实际的演出安排中,两首歌都没有达到嘉宾的要求,那么嘉宾就会对音乐节不滿意。如嘉...原创 2018-03-28 21:41:57 · 176 阅读 · 0 评论 -
#1174 : 拓扑排序·一
描述由于今天上课的老师讲的特别无聊,小Hi和小Ho偷偷地聊了起来。小Ho:小Hi,你这学期有选什么课么?小Hi:挺多的,比如XXX1,XXX2还有XXX3。本来想选YYY2的,但是好像没有先选过YYY1,不能选YYY2。小Ho:先修课程真是个麻烦的东西呢。小Hi:没错呢。好多课程都有先修课程,每次选课之前都得先查查有没有先修。教务公布的先修课程记录都是好多年前的,不但有重复的信息,好像很多都不正确...原创 2018-03-13 23:08:50 · 394 阅读 · 0 评论 -
#1183 : 连通性一·割边与割点
描述还记得上次小Hi和小Ho学校被黑客攻击的事情么,那一次攻击最后造成了学校网络数据的丢失。为了避免再次出现这样的情况,学校决定对校园网络进行重新设计。学校现在一共拥有N台服务器(编号1..N)以及M条连接,保证了任意两台服务器之间都能够通过连接直接或者间接的数据通讯。当发生黑客攻击时,学校会立刻切断网络中的一条连接或是立刻关闭一台服务器,使得整个网络被隔离成两个独立的部分。举个例子,对于以下的网...原创 2018-03-13 22:56:14 · 264 阅读 · 0 评论 -
Stockbroker Grapevine (弗洛伊德)
Problem 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 the tactica原创 2017-08-05 20:06:21 · 349 阅读 · 0 评论 -
Wormholes (弗洛伊德 )
Problem 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 its desti原创 2017-08-04 21:15:12 · 443 阅读 · 1 评论 -
Arbitrage
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 D原创 2017-08-05 20:25:23 · 408 阅读 · 0 评论 -
POJ - 1515(割边)
According to the Automobile Collision Monitor (ACM), most fatal traffic accidents occur on two-way streets. In order to reduce the number of fatalities caused by traffic accidents, the mayor wants to ...原创 2019-01-18 20:24:23 · 187 阅读 · 0 评论 -
HDU - 3849 (求割边--输入输出)
Social Network is popular these days.The Network helps us know about those guys who we are following intensely and makes us keep up our pace with the trend of modern times. But how? By what method c...原创 2019-01-18 19:59:07 · 195 阅读 · 0 评论 -
HDU - 5093(二分图经典建图)
Dear contestant, now you are an excellent navy commander, who is responsible of a tough mission currently. Your fleet unfortunately encountered an enemy fleet near the South Pole where the geographic...原创 2019-01-18 19:54:59 · 244 阅读 · 1 评论 -
3631. Delivery Service(倍增lca+树上差分)
EOJ Delivery Service Company handles a massive amount of orders in our nation. As is well known, our nation has n cities, with n−1 bi-directional paths connecting them, forming a tree. The length of t...原创 2018-08-18 16:59:25 · 619 阅读 · 0 评论 -
D. Fair(多源bfs)
D. Fairtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputSome company is going to hold a fair in Byteland. There are nn towns in Byteland and mm two...原创 2018-05-30 21:17:54 · 895 阅读 · 3 评论 -
World Exhibition(差分约束--线性约束模板题)
Problem DescriptionNowadays, many people want to go to Shanghai to visit the World Exhibition. So there are always a lot of people who are standing along a straight line waiting for entering. Assume t...原创 2018-05-22 17:22:52 · 268 阅读 · 0 评论 -
FZU - 2277(树链剖分或dfs序+线段树)
There is a rooted tree with n nodes, number from 1-n. Root’s number is 1.Each node has a value ai.Initially all the node’s value is 0.We have q operations. There are two kinds of operations.1 v x k : ...原创 2018-04-28 10:06:15 · 261 阅读 · 0 评论 -
Agri-Net
Problem DescriptionFarmer 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 help, of course.Farmer原创 2017-08-04 21:29:37 · 199 阅读 · 0 评论 -
Highways
Problem 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 aware of this原创 2017-08-04 21:26:53 · 323 阅读 · 0 评论 -
Frogger
Problem 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 dirty and原创 2017-08-04 21:32:49 · 299 阅读 · 0 评论 -
Sorting It All Out (拓扑排序)
Problem 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 sorted s原创 2017-08-08 19:51:52 · 287 阅读 · 0 评论 -
#1369 : 网络流一·Ford-Fulkerson算法
时间限制:10000ms单点时限:1000ms内存限制:256MB描述小Hi和小Ho住在P市,P市是一个很大很大的城市,所以也面临着一个大城市都会遇到的问题:交通拥挤。小Ho:每到周末回家感觉堵车都是一种煎熬啊。小Hi:平时交通也还好,只是一到上下班的高峰期就会比较拥挤。小Ho:要是能够限制一下车的数量就好了,不知道有没有办法可以知道交通系统的最大承受车流量,这样就可以限制到一个可以一直很顺畅的数...原创 2018-03-20 00:01:56 · 177 阅读 · 0 评论 -
Control (网络流最小割)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4289题目大概:恐怖分子从一个城市要到达另一个城市,要想半路拦截住恐怖恐怖分子,就要控制城市,在恐怖分子来的时候,抓住,每个城市都有费用,问拦截住恐怖分子的最小费用是多少。思路:是一道最小割的题。因为每个城市有价值,可以拆点,来控制流量。s连开始的城市,容量无穷,最后的城市连t汇原创 2018-02-06 21:02:08 · 164 阅读 · 0 评论 -
Power Network (网络流)
题目链接:http://poj.org/problem?id=1459题目大概:在一个电力网络中,有发电站,有用户,有中间传输点,问这个电网的最大输出功率。思路:模板来自 poursoul基本的网络流的题,建模过程没有什么技巧。源点s连所有发电站,容量为发电站的功率,用户连汇点t,容量为用户要用的功率,中间结点,题目说怎么连就怎么连。感想:这道题没有什么可以注意的,原创 2018-02-06 14:46:50 · 461 阅读 · 0 评论 -
Going Home (费用流)
题目链接:http://poj.org/problem?id=2195题目大概:模板来自 poursoul在一个矩形地图中,有n个人要去n个房子里去,一个人每走一格花费1元,问最少花费为多少。思路:计算出n个人中的每个人与n个房子的距离w,然后开始建图。s连每个人,容量为1,人连房子,容量为1,费用为w,房子连t,容量为1.最后跑一遍费用流。感想:有时候可以把一原创 2018-02-05 21:11:04 · 245 阅读 · 0 评论 -
Dining (网络流)
题目链接:http://poj.org/problem?id=3281题目大概:一个农夫有食物和饮料来喂养n头牛,每头牛都有自己喜欢的食物和饮料,其他的不要,问最多养活几头牛。思路:模板来自大神 poursoul这个网络流的题牛需要两样物品,也就是要匹配两个,可以把食物和饮料放到牛的两边,s--食物--牛--饮料--t,这样来建图,因为一头牛可能会走通两条路,为了限制一下,把牛原创 2018-02-05 20:59:40 · 273 阅读 · 0 评论 -
Rank of Tetris (拓扑排序+并查集+缩点)
自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球。为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜,定时更新,名堂要比福布斯富豪榜还响。关于如何排名,这个不用说都知道是根据Rating从高到低来排,如果两个人具有相同的Rating,那就按这几个人的RP从高到低来排。 终于,Lele要开原创 2018-01-28 23:01:20 · 256 阅读 · 0 评论 -
John's trip (欧拉路)
Little Johnny has got a new car. He decided to drive around the town to visit his friends. Johnny wanted to visit all his friends, but there was many of them. In each street he had one friend. He star原创 2018-01-28 22:42:32 · 527 阅读 · 0 评论 -
Codeforces Round #435 (Div. 2)B. Mahmoud and Ehab and the bipartiteness(补)
Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees.A tree is a connected acyclic graph. A bipartite graph is a graph原创 2017-09-21 20:13:30 · 224 阅读 · 0 评论 -
1007(优先队列)
Problem DescriptionXiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao what the kth great number is. Because the number原创 2017-08-22 20:19:02 · 341 阅读 · 0 评论 -
Borg Maze (bfs+最小生成树)
Problem 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 consciousness of the原创 2017-08-09 12:09:28 · 340 阅读 · 0 评论 -
确定比赛名次(拓扑排序)
题目大概:输入有多个数据,输入n,m,接下来有n个队伍参加了m场比赛,接下来m行每行两个数p1,p2,是p1赢了p2,p1要排在p2前面,输出排名(不唯一)。思路:因为这个题中是无环有向图,所有可以用拓扑排序。拓扑排序可以定义一个map来记录那两个队有比赛谁赢了,map【a】【b】=1;代表a赢了b。还可以有入度记录r【】,记录入度个数。出度个数c【】。所有数据存入后,原创 2017-06-25 14:24:46 · 702 阅读 · 0 评论 -
Fire Net (二分图最大匹配)
Suppose 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 or a piece of wall. A blockhouse is a small castle tha...原创 2018-03-04 22:34:34 · 1761 阅读 · 0 评论 -
The Accomodation of Students (二分图判断+二分图最大匹配)
There 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....原创 2018-03-04 22:58:49 · 184 阅读 · 0 评论 -
Courses (二分图最大匹配)
Consider 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 sa...原创 2018-03-04 23:05:43 · 268 阅读 · 0 评论 -
#1398 : 网络流五·最大权闭合子图
时间限制:10000ms单点时限:1000ms内存限制:256MB描述周末,小Hi和小Ho所在的班级决定举行一些班级建设活动。根据周内的调查结果,小Hi和小Ho一共列出了N项不同的活动(编号1..N),第i项活动能够产生a[i]的活跃值。班级一共有M名学生(编号1..M),邀请编号为i的同学来参加班级建设活动需要消耗b[i]的活跃值。每项活动都需要某些学生在场才能够进行,若其中有任意一个学生没有被...原创 2018-03-19 23:57:14 · 353 阅读 · 0 评论 -
#1394 : 网络流四·最小路径覆盖
时间限制:10000ms单点时限:1000ms内存限制:256MB描述国庆期间正是旅游和游玩的高峰期。小Hi和小Ho的学习小组为了研究课题,决定趁此机会派出若干个调查团去沿途查看一下H市内各个景点的游客情况。H市一共有N个旅游景点(编号1..N),由M条单向游览路线连接。在一个景点游览完后,可以顺着游览线路前往下一个景点。为了避免游客重复游览同一个景点,游览线路保证是没有环路的。每一个调查团可以从...原创 2018-03-19 23:36:19 · 220 阅读 · 0 评论 -
#1185 : 连通性·三(强连通分量+缩点+拓扑排序)
时间限制:10000ms单点时限:1000ms内存限制:256MB描述暑假到了!!小Hi和小Ho为了体验生活,来到了住在大草原的约翰家。今天一大早,约翰因为有事要出去,就拜托小Hi和小Ho忙帮放牧。约翰家一共有N个草场,每个草场有容量为W[i]的牧草,N个草场之间有M条单向的路径。小Hi和小Ho需要将牛羊群赶到草场上,当他们吃完一个草场牧草后,继续前往其他草场。当没有可以到达的草场或是能够到达的草...原创 2018-03-19 23:18:49 · 465 阅读 · 0 评论 -
#1122 : 二分图二•二分图最大匹配之匈牙利算法
描述上一回我们已经将所有有问题的相亲情况表剔除了,那么接下来要做的就是安排相亲了。因为过年时间并不是很长,所以姑姑希望能够尽可能在一天安排比较多的相亲。由于一个人同一天只能和一个人相亲,所以要从当前的相亲情况表里选择尽可能多的组合,且每个人不会出现两次。不知道有没有什么好办法,对于当前给定的相亲情况表,能够算出最多能同时安排多少组相亲呢?同样的,我们先将给定的情况表转换成图G=(V,E)。在上一回...原创 2018-03-13 22:39:46 · 174 阅读 · 0 评论