【赛后补题】蔚来杯

A - Villages:Landlines

(1)翻译:

  The game development team NIO Tech releases its debut game, Villages: Landlines. In this game, players develop their villages and enjoy their peaceful country life.

  游戏开发团队NIO-tech发布了他们的第一款游戏——Villages:Landlines。在这个游戏中,玩家发展他们的村庄,享受他们平静的乡村生活。

  The game Villages: Landlines contains a one-dimensional power system. Initially, there are several power stations and buildings. The goal of the game is to make every power stations and buildings connected together in the power system, forming a connected graph. Players can build some power towers and wires in the game, which are the tools to connect power stations and buildings.

  游戏Villages: Landlines 包含一个一维的电力系统。最初,有少数power stations(发电站)和buildings(建筑)。游戏目标是使每个power stations和buildings在电力系统中联系在一起,形成一张连通图。玩家可以在游戏中建设一些power towers和wires,他们是连接power stations和buildings的工具。

  Power stations or buildings can connect to power towers without wires, while power towers must connect to each other by wires. What's more, power stations and buildings can't connect to each other directly, they must connect through power towers.

  Power stations 或者 buildings可以不用wires连到power towers,但是power towers之间必须用wires连接。另外,power stations和buildings不能互相连接,他们必须通过power towers进行连接。


Assuming that the coordinate of a building is xix_ixi and its receiving radius is rir_iri, all the power towers whose distance from the building is no greater than rir_iri are directly connected to it without wires. That is to say, for the power tower located at xxx, it is directly connected to the building at xix_ixi without wires if and only if ∣x−xi∣≤ri|x-x_i|\leq r_ixxiri. Similarly, assuming that the power supply radius of a power station is rsr_srs, all the power towers whose distance from the power station is no more than rsr_srs are directly connected to it without wires. Supposing that the coordinates of two power towers are xAx_AxA and xBx_BxB, players can connect them with the wire, and the length of wire required is ∣xA−xB∣|x_A-x_B|xAxB∣. A power tower can be connected to any number (possibly zero) of power towers, buildings and power stations.

In order to make the game more friendly to the rookies, Nostalgia, a member of NIO Tech, decides to develop the power distribution recommendation function. In the case of using any number of power towers, players can choose exactly one power station and several buildings to get an optimal power supply scheme, which uses the shortest total length of wires to complete the power system. However, Nostalgia is not sure whether her scheme is correct, so she needs your help to calculate the total length of wires used in the optimal scheme to determine the correctness of her scheme.

Note that the players can build a new power tower at coordinate xxx even if there exists a power station or a building at xxx. There might be more than one power station or building at the same coordinate.

 

posted @ 2022-07-30 22:14  心若笺诗  阅读(44)  评论(0编辑  收藏  举报