当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3391:The Bug Sensor Problem

题目描述

Mr. Macdonald is a farmer. He has a huge land to manage. To monitor the number of bugs in his land, he asks help from the famous professor T. Professor T is an expert on computer science.

Professor T studies several efficient approach and suggests Mr. Macdonald to setup a wireless sensor system in his land. The system will be setup as follows:

In each predefined location, one wireless sensor will be established. Since all sensors are operated by batteries, the powers consumed by the sensors are determined by the effective communication distance (ECD) between sensors. Mr. Macdonald is a nice old man. He prefers not to trouble professor T much. Therefore, he decides that all sensors will be set in the same power level. That is, all sensors will have the same effective communication distance.

The land is so huge that it is not possible to cover all spots by the sensors. However, each sensor can broadcast the collected data to their neighbors as long as the neighbors are in its effective communication distance. But the total number of sensors is relative small comparing to the land. Mr. Macdonald needs to travel the whole land to collect the data from sensors everyday.

Mr. Macdonald is getting old. He hopes that the computer in his house can collect all data from all sensors automatically. Again, he called professor T for help. This time, professor T suggests Mr. Macdonald to setup a base station in his house. The house is right in the center of the land.

Due to the limited budget, the number of receiver transmitter Mr. Macdonald can afford is limited and is relatively small comparing to the total number of sensors. It is impossible to assign receiver transmitter to every sensor. Therefore, sensors with no receiver transmitter need to send their data to the sensor with receiver transmitter (directly or indirect) first, After that, the sensor with receiver transmitter sends all data it receives from other sensors along with the data it collects back to the base station. You may assume that the receiver transmitter has enough power such that it always can send data back to the base station.

Professor T promises to write the necessary software to make all sensors work together in this way, but one important issue need to be studied. If all sensors are set at the maximum power level, all sensors might be able to send their data back without troubles, but the battery will be out-of-power soon. To save power, professor T need to decide the minimum power level needed such that the battery can have longest operating time while all sensor data can be collected by the base station.

Although professor T is good in programming, he is weak in algorithm design. Your goal is to help professor T to write a program to determine the minimum power level needed to set all sensors accordingly. To simplify our problem, please report the ECD corresponding to the minimum power level. Please apply the ceiling function to your answer.

Here is an example:

Assume that the land is 10 × 10. There are three sensors, located at (1,1), (2,1) and (8,7). We also assume that there are 2 receiver transmitters. In this example, the ECD of all sensors need to be set at 1.

输入解释

The first line contains the number of test cases w, 1 ≤ w ≤ 10. Then the w test cases are listed one by one. In each test case, the first line is a single integer, representing the number of receiver transmitters for that test case. After that, the test case consists of some lines with two numbers each line:

X Y

Here two numbers are separated by a single blank, X is an integer, denoting the x-coordinate of the sensor, and Y is also an integer, denoting the y-coordinate of the same sensor. Each test case is ended by the following line: −1.

Please note that the land is a rectangle with dimensions 100000 × 100000.

输出解释

For each test case, output the corresponding ECD.

输入样例
1
2
1 1
2 1
8 7
-1
输出样例
1
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 5000MS

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Kaohsiung 2006

源链接: POJ-3391

最后修改于 2020-10-29T07:00:26+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000 65536