编程介的小学生 2019-12-03 00:10 采纳率: 20.5%
浏览 52

Locate Mining Center 的一个具体的思路

Problem Description
As part of a peace treaty with the Navi, the humans are allowed mine for Unobtainium in a remote, deserted area of Pandora. The scientists have identified many possible excavation sites, and are now trying to figure out where to place the Mining Center. The placement of the mining center is further constrained by the fact that the robots that will carry the Unobtainium from the excavation sites to the mining center can only walk along prespecified Grid lines (see figure). The goal is now to find the location of the mining center so that the maximum distance to the excavation sites is minimized. You are to write a program for finding that location.

Specifically, you are given the x- and y-coordinates of the excavations sites, (x1, y1), (x2, y2), ...(xn, yn) (n denotes the number of excavation sites). You are to find the coordinates for the Mining Center, (x0, y0), so that the maximum of the distances between the mining center and the excavation sites is minimized. All coordinates must be integers. The distance metric to be used is the rectilinear distance (also called Manhattan distance). Specifically, the rectilinear distance between (x0, y0) and (xi, yi) is:

|xi - x0| + |yi - y0|

Further, if there are multiple locations which qualify, then you must find the location that is closest to the origin by Euclidean distance q metric. Since origin is at (0, 0), this corresponds to minimizing .

In other words, given the input (x1, y1), ..., (xn, yn), your goal is to find (x0, y0) such that:

is minimized, and if there are multiple answers, then is the smallest among all such answers.

Input
The first line in the test data file contains the number of test cases, n. After that, each line contains one test case. The test case begins with the number of mines, followed by the x and y coordinates of each mine. All coordinates must be integers. Very large coordinate values may be used (million+), so brute force methods will not work.

Output
For each test case, you are to output a line beginning with ”LOCATION”, followed by the x and y coordinates of the mining center. All coordinates must be integers.

Sample Input
2
4 100 0 40 0 -10 0 20 0
3 245 692 -772 -647 330 526

Sample Output
LOCATION 45 0
LOCATION -121 -120

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能
    • ¥15 jmeter脚本回放有的是对的有的是错的
    • ¥15 r语言蛋白组学相关问题