POJ 1944 - Fiber Communications】的更多相关文章

原题地址:http://poj.org/problem?id=1944 题目大意:有n个点排成一圈,可以连接任意两个相邻的点,给出 p 对点,要求这 p 对点必须直接或间接相连,求最少的连接边数 数据范围:n <= 1000, p <= 10000 算法分析: 一开始当最小生成树做的,才发现自己 SB 了…… 先考虑不是环形而是线形的结构,直接贪心连接每两个点之间的所有点就好了.这样我们可以枚举环形的断点,然后逐次贪心,求最小解即可 很多同学在贪心的时候应用了线段树是复杂度高达O(np log…
题意 在一个有N(1 ≤ N ≤ 1,000)个点环形图上有P(1 ≤ P ≤ 10,000)对点需要连接.连接只能连接环上相邻的点.问至少需要连接几条边. 思路 突破点在于最后的结果一定不是一个环!所以我们枚举断边,则对于P个连接要求都只有唯一的方法:如果一个pair的两个端点在断点两侧,就分成[0,left],[right,N];否则就是[left, right].这里区间以0开头是要考虑left=1.right=N的情况,至少得有个边([0, 1])表示N连向1的情况不是么. 处理一个区间…
Fiber Communications Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 4236   Accepted: 1276 Description Farmer John wants to connect his N (1 <= N <= 1,000) barns (numbered 1..N) with a new fiber-optic network. However, the barns are loc…
Fiber Communications Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3804   Accepted: 1160 Description Farmer John wants to connect his N (1 <= N <= 1,000) barns (numbered 1..N) with a new fiber-optic network. However, the barns are loc…
Fiber Communications 总时间限制:  1000ms 内存限制:  65536kB 描述 Farmer John wants to connect his N (1 <= N <= 1,000) barns (numbered 1..N) with a new fiber-optic network. However, the barns are located in a circle around the edge of a large pond, so he can on…
1550: Fiber Communications  Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByteTotal Submit: 3            Accepted:2 Description Farmer John wants to connect his N (1 <= N <= 1,000) barns (numbered 1..N) with a new fiber-optic network…
Fiber Network Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3328   Accepted: 1532 Description Several startup companies have decided to build a better Internet, called the "FiberNet". They have already installed many nodes that ac…
Description Farmer John wants to connect his N (1 <= N <= 1,000) barns (numbered 1..N) with a new fiber-optic network. However, the barns are located in a circle around the edge of a large pond, so he can only connect pairs of adjacent barns. The ci…
题目翻译 一些公司决定搭建一个更快的网络.称为"光纤网". 他们已经在全世界建立了很多网站.这 些网站的作用类似于路由器.不幸的是,这些公司在关于网站之间的接线问题上存在争论,这样"光纤网"项目就被迫终止了,留下的是每一个公司自己在某些网站之间铺设的线路. 如今,Internet 服务供应商.当想从网站 A传送数据到网站 B,就感到困惑了.究竟哪个公司 可以提供必要的连接. 请帮助供应商回答他们的查询.查询全部可以提供从网站 A到站定 B的线 路连接的公司. 输入描…
枚举起点和公司,每次用DFS跑一遍图,预处理出所有的答案.询问的时候很快就能得到答案. #include<cstdio> #include<cmath> #include<cstring> #include<vector> #include<algorithm> using namespace std; ][][]; ][][]; ]; vector<]; int n; int S,T,G; void DFS(int now) { ans[…