POJ - 1815 Friendship (最小点割集)】的更多相关文章

(点击此处查看原题) 题目分析 题意:有n个人,编号记为1~n,n个人之间可能有人可以互相联系,如果A能和B联系,那么至少满足这两种情况之一:(1)A知道B的电话(2)A可以和C联系,并且C可以和B联系: 因为某些人可能会丢失他的手机,导致他失去所有人的号码以及其他人手机中他的号码,也就是说这个人无法和任何人联系了: 此时给出两个人s,t,问至少有多少人失去他们的手机,可以使得这两个人s,t无法联系. 答案输出最少需要的人数以及失去手机的人的编号,如果存在多组解,输出字典序小的那一组. 思路:平…
http://poj.org/problem? id=1815 Friendship Time Limit: 2000MS   Memory Limit: 20000K Total Submissions: 9026   Accepted: 2534 Description In modern society, each person has his own friends. Since all the people are very busy, they communicate with ea…
题意: 就在一个给定的无向图中至少应该去掉几个顶点才干使得s和t不联通. 算法: 假设s和t直接相连输出no answer. 把每一个点拆成两个点v和v'',这两个点之间连一条权值为1的边(残余容量) v和v''各自是一个流进的点.一个流出的点. 依据求最小割的性质.权值小的边是可能被选择的(断开的). 加入源点st=0和汇点en=2*n+1,源点与s连权值为inf的边.t''与汇点连权值为inf的边. s与s'',t与t''连权值为inf的边,这样保证自己和自己是不会失去联系的. 假设i和j有…
妖怪题目,做到现在:2017/8/19 - 1:41…… 不过想想还是值得的,至少邻接矩阵型的Dinic算法模板get√ 题目链接:http://poj.org/problem?id=1815 Time Limit: 2000MS Memory Limit: 20000K Description In modern society, each person has his own friends. Since all the people are very busy, they communic…
[题意]给出一个无向图,和图中的两个点s,t.求至少去掉几个点后才能使得s和t不连通,输出这样的点集并使其字典序最大. 不错的题,有助于更好的理解最小割和求解最小割的方法~ [思路] 问题模型很简单,就是无向图的点连通度,也就是最小点割集.麻烦之处在于需要使得点割集方案的字典序最大.这样的话通常的dfs划分点集的方法就行不通了.我们采取贪心的策略:枚举1~N的点,在残留网络中dfs检查其代表的边的两端点是否连通,如果不连通则该点可以为点割,那么我们就让他是点割,加入到答案中,然后删掉这条边更新最…
Friendship Time Limit: 2000MS   Memory Limit: 20000K Total Submissions: 10744   Accepted: 2984 Description In modern society, each person has his own friends. Since all the people are very busy, they communicate with each other only by phone. You can…
题目链接:http://poj.org/problem?id=1815 In modern society, each person has his own friends. Since all the people are very busy, they communicate with each other only by phone. You can assume that people A can keep in touch with people B, only if 1. A kno…
Friendship Time Limit: 2000MS   Memory Limit: 20000K Total Submissions: 8025   Accepted: 2224 Description In modern society, each person has his own friends. Since all the people are very busy, they communicate with each other only by phone. You can…
http://poj.org/problem?id=1815 题意: 在现代社会,每个人都有自己的朋友.由于每个人都很忙,他们只通过电话联系.你可以假定A可以和B保持联系,当且仅当:①A知道B的电话号码:②A知道C的电话号码,而C能联系上B.如果A知道B的电话号码,则B也知道A的电话号码. 思路:这题是要我们删点,既然是删点,那么就要拆点,容量就是1. 接下来凡是能联系的,就连边,容量为INF,因为我们不是要删除这些边.跑遍最大流就能算出至少要删除多少个点. 这道题的关键是要字典序顺序输出最小割…
网络流的题总是出各种奇怪的错啊--没写过邻接表版的dinic,然后bfs扫到t点不直接return 1就会TTTTTLE-- 题目中的操作是"去掉人",很容易想到拆点,套路一般是(s,i')(i,t)(u',v)(v,u),然后关于输出顺序最小方案,可以枚举删点,如果删去一个点后求得最小割比原来的小,那么说明这个点在最小割中,就在图中删掉它并且把最小割标准-1,否则把这个点加回来. #include<iostream> #include<cstdio> #inc…
Friendship Time Limit: 2000MS   Memory Limit: 20000K Total Submissions: 10626   Accepted: 2949 Description In modern society, each person has his own friends. Since all the people are very busy, they communicate with each other only by phone. You can…
题目链接:http://poj.org/problem?id=1815 思路:题目要求是剔除多少个点,可以将其转化为剔除多少条边,因此需要拆点,将点i拆成i,i+n,便容量为1,表示每个人起的传递作用只能是一次.然后就是枚举了,删除某条边,如果求出的最小割比原来的要小,说明减少的是割边集. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<…
Friendship Time Limit: 2000MS   Memory Limit: 20000K Total Submissions: 11429   Accepted: 3173 Description In modern society, each person has his own friends. Since all the people are very busy, they communicate with each other only by phone. You can…
Description In modern society, each person has his own friends. Since all the people are very busy, they communicate with each other only by phone. You can assume that people A can keep in touch with people B, only if  1. A knows B's phone number, or…
                                Cable TV NETWORK The interconnection of the relays in a cable TV network is bi-directional. The network is connected if there is at least one interconnection path between each pair of relays present in the network. Oth…
POJ 3356 AGTC(最小编辑距离) http://poj.org/problem?id=3356 题意: 给出两个字符串x 与 y,当中x的长度为n,y的长度为m,而且m>=n.然后y能够经过删除一个字母,加入一个字母,转换一个字母,三种操作得到x.问最少能够经过多少次操作 分析: 我们令dp[i][j]==x表示源串的前i个字符变成目串的前j个字符须要x步操作. 初始化: dp[0][i]==i且 dp[i][0]=i. 上述前者表示加入源串i个字符, 后者表示删除源串i个字符. 状态…
http://poj.org/problem?id=1966 题意:给出一个由n个点,m条边组成的无向图.求最少去掉多少点才能使得图中存在两点,它们之间不连通. 思路:将点i拆成a和b,连一条a->b的容量为1的边,代表这个点只能走一次,然后如果点i和点j有边相连,那么将bi和aj相连,bj和ai相连,容量为INF,代表这条边可以走INF次. 然后O(n^2)枚举源点和汇点跑最大流,算的最小的最大流就是答案.(这个时候的最大流代表的是S跑到T需要经过多少路径(最小割),如果得到的最大流是INF,…
In modern society, each person has his own friends. Since all the people are very busy, they communicate with each other only by phone. You can assume that people A can keep in touch with people B, only if 1. A knows B’s phone number, or 2. A knows p…
题目链接:http://poj.org/problem?id=3020 题目大意:读入一张地图.其中地图中圈圈代表可以布置卫星的空地.*号代表要覆盖的建筑物.一个卫星的覆盖范围是其周围上下左右四个点.问最少需要几个卫星才能覆盖所有建筑物. 解题思路: 有点类似POJ 1328的覆盖题,不过那题比较简单可以贪心.这题你可以YY试试. 覆盖问题其实可以用图论解决.这题就属于最小路径覆盖,手动由一个点出发连一些路径,这样Hungry就能求出最少需要多少这样的中心点,就可以达成目标了. 本题最大的疑问是…
题目链接 The Windy's | Time Limit: 5000MS | Memory Limit: 65536K | | Total Submissions: 4939 | Accepted: 2080 | Description The Windy's is a world famous toy factory that owns M top-class workshop to make toys. This year the manager receives N orders for…
题目链接:http://poj.org/problem?id=1325 Machine Schedule Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14216   Accepted: 6075 Description As we all know, machine scheduling is a very classical problem in computer science and has been studi…
Description It is year 2500 A.D. and there is a terrible war between the forces of the Earth and the Mars. Recently, the commanders of the Earth are informed by their spies that the invaders of Mars want to land some paratroopers in them× n grid yard…
http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17543   Accepted: 9548 Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <…
Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22905   Accepted: 12421 Description Bessie 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 a…
题意:N*M个格点,K个位置会有敌人.每行每列都有一门炮,能打掉这一行(列)上所有的敌人.每门炮都有其使用价值.总花费是所有使用炮的权值的乘积.求最小的总花费. 若每门炮的权值都是1,就是求最小点覆盖的问题,参考:http://poj.org/problem?id=3041 将行视作X部,列视作Y部,敌人(i,j)视作连接点i和点N+j的边,要求一个点集合,使其能覆盖所有的边,且权值之积最小,即求最小点权覆盖.与求最大权独立集一样,也是用网络流求解. 这里处理积的方法是,将权值取对数,则log(…
题目链接:http://poj.org/problem?id=3084 思路:题目的意思是不让入侵者进入保护的房间,至少需要锁几道门.网络流建模:设一个超级源点,源点与有入侵者的房间相连,边容量为inf,对于那些被入侵的房间,假设房间a有们通往b,则连边a->b,容量为inf,连边b->a,容量为1,因为控制权在a,所以只要进入房间a,就能进入房间b,而相反,对于那些进入房间b的入侵者, 只要锁上了a与b之间的那扇门,就无法进入房间a了,因此连边1.最后就是跑最大流求最小割就行了. #incl…
题目链接:http://poj.org/problem?id=3204 思路:显然只有增大那最小割边集上的边才能增加最大流,因此,我们可以先跑一遍最大流,然后对于那些满足条件的边u->v,当且仅当从源点开始沿着正向边能遍历到u,从汇点开始沿着正向边能遍历到v. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> u…
http://poj.org/problem?id=3041 题目大意: 一辆宇宙飞船在一个小行星带中,你知道,这很危险.他有一种武器,可以清除掉一行或一列的小行星.问把小行星全部清除最少的武器使用次数. 思路: 因为每次可以清除掉一行或者一列,所以可以把行和列建成图,行和列为边,因为最后要全部清除,也就是说所有边都使用过,正好就是最小覆盖数. 最小覆盖数=最大匹配. #include<cstdio> #include<cstring> const int MAXN=500+10;…
POJ - 3164 题意: 一个有向图,存在从某个点为根的,可以到达所有点的一个最小生成树,则它就是最小树形图. 题目就是求这个最小的树形图. 参考资料:https://blog.csdn.net/txl199106/article/details/62045479 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <strin…
   Asteroids POJ - 3041 Bessie 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 <= K <= 10,000), which are conveniently located at the lattice po…