#ahc020a. [ahc020_a]Broadcasting
[ahc020_a]Broadcasting
Story
AtCoder regularly broadcasts its official live broadcast "A-Da-Coder" on the Internet to provide the latest news and to interact with users. To reach a wider audience, CEO Takahashi decided to build a TV network to broadcast the live stream to all residents of AA City.
The TV network of AA city is represented by a weighted planar undirected graph with broadcast stations as vertices and cables between stations as edges. AtCoder's office is located in the same building as broadcast station located at coordinates . You can turn power ON/OFF for each cable, and each station that can be reached from the station using only the cables with power ON can transmit radio waves for broadcasting. You can adjust the output strength of the broadcast radio waves for each station, and the area in which live broadcasts are delivered depends on the output strength.
Please build a TV network that can deliver live broadcasts to all residents while reducing the cost of using transmission cables and the cost of transmitting radio waves for broadcasts.
Problem Statement
You are given a weighted planar undirected graph with vertices and edges. The coordinates of vertex are . The -th edge connects vertices and with the weight . Let $D_j=\\mathrm{round}\\left(\\sqrt{(x_{u_j}-x_{v_j})^2+(y_{u_j}-y_{v_j})^2}\\right)$ be the rounded Euclidean distance between vertices and . Then, weight satisfies . You are also given coordinates of the residents, and the coordinates of -th resident are .
You should set the power ON/OFF for each edge and the output strength integer for each vertex . Let be the set of edges whose power is ON. Consider a subgraph obtained from by removing edges not included in , and let be the set of vertices reachable from vertex in . For each , residents living within a circular region of radius centered at coordinates (including the circumference) will be able to view the live broadcast.
Setting the power of edge to ON incurs a cost . Also, setting the output strength of vertex to incurs a cost . You may set to a positive value for , but this will not expand the broadcasting coverage area and incurs unnecessary costs. Please build a TV network that can deliver live broadcasts to all residents while reducing the sum of the costs as small as possible.
Scoring
Let be the number of residents in the coverage area of the live broadcast. Then you will obtain the following score.
- If , .
- If , .
Note that may not fit into the 32-bit integer.
There are 300 test cases, and the score of a submission is the total score for each test case. The input for seed=0 is manually created and is not included in the test cases. If your submission produces an illegal output or exceeds the time limit for some test cases, the submission itself will be judged as WA