Uva10859 - Placing Lampposts
2015-07-15 21:05
183 查看
As a part of the mission `Beauti cation of Dhaka City', the government has decided to replace all the
old lampposts with new expensive ones. Since the new ones are quite expensive and the budget is not
up to the requirement, the government has decided to buy the minimum number of lampposts required
to light the whole city.
Dhaka city can be modeled as an undirected graph with no cycles, multi-edges or loops. There are
several roads and junctions. A lamppost can only be placed on junctions. These lampposts can emit
light in all the directions, and that means a lamppost that is placed in a junction will light all the roads
leading away from it.
The `Dhaka City Corporation' has given you the road map of Dhaka city. You are hired to nd
the minimum number of lampposts that will be required to light the whole city. These lampposts can
then be placed on the required junctions to provide the service. There could be many combinations of
placing these lampposts that will cover all the roads. In that case, you have to place them in such a
way that the number of roads receiving light from two lampposts is maximized.
Input
There will be several cases in the input le. The rst line of input will contain an integer T (T 30)
that will determine the number of test cases. Each case will start with two integers N (N 1000)
and M (M < N) that will indicate the number of junctions and roads respectively. The junctions are
numbered from 0 to N
old lampposts with new expensive ones. Since the new ones are quite expensive and the budget is not
up to the requirement, the government has decided to buy the minimum number of lampposts required
to light the whole city.
Dhaka city can be modeled as an undirected graph with no cycles, multi-edges or loops. There are
several roads and junctions. A lamppost can only be placed on junctions. These lampposts can emit
light in all the directions, and that means a lamppost that is placed in a junction will light all the roads
leading away from it.
The `Dhaka City Corporation' has given you the road map of Dhaka city. You are hired to nd
the minimum number of lampposts that will be required to light the whole city. These lampposts can
then be placed on the required junctions to provide the service. There could be many combinations of
placing these lampposts that will cover all the roads. In that case, you have to place them in such a
way that the number of roads receiving light from two lampposts is maximized.
Input
There will be several cases in the input le. The rst line of input will contain an integer T (T 30)
that will determine the number of test cases. Each case will start with two integers N (N 1000)
and M (M < N) that will indicate the number of junctions and roads respectively. The junctions are
numbered from 0 to N
相关文章推荐
- Linux 内存管理之 mmap 解析(二)
- POJ 1837 Balance (多重背包计数)
- bzoj1148
- DraggableGridView可拖动的GridView
- 要看的书单
- bzoj1145
- Objective-C中的@property和@synthesize用法
- 怎么计算两个日期之间的差值
- hdu2199
- ubuntu 重新安装mysql
- POJ 3615 Cow Hurdles //Floyd算法
- Chrome谷歌浏览器如何禁用JavaScript
- iOS中的c第二天分支语句
- bzoj1146
- Codeforces Round #202 (Div. 2) C. Mafia
- Nginx 定义自己的 http 模块
- 安卓开班自我介绍
- Android之——多线程断点续传下载示例
- 4.3堆积面积图
- SVN合并(merge)的使用