bzoj#P1351. [Baltic2006]COUNTRIES
[Baltic2006]COUNTRIES
题目描述
This problem considers how mighty countries arise from humble beginnings. Consider a two-dimensional map of the area. On this map there are n cities. Each city is in a distinct location with coordinates on the map. The city has also a number of soldiers in it under the command of a general.
The influence city exerts to another location is computed as divided by the squared distance between it and . It is as if the mass of soldiers in city exerted a gravitational pull to all map locations around it. City is threatened by another city if the influence exerted by city on the location of city exceeds its number of soldiers : then city can dispatch enough soldiers to overpower all the soldiers defending city . If city is not threatened by any other city , then its grateful citizens elect its invincible general as their king, and turn their city into the capital of his kingdom.
On the other hand, if some city threatening city exerts strictly more influence on its location than any other city , then the citizens of city have no choice: city must surrender to city . Henceforth city must obey the same capital as city obeys; however, the soldiers in city do not join the army of city or the capital. Otherwise city is saved by mutual distrust of the equally threatening cities and : If one of them would attack and overpower city , then the other would in turn attack and overpower the battle-weary first attackers. However, the citizens of city can no longer elect its general as their king, because he has failed in his duty to keep the city safe from threats. Thus they must turn their city into the capital of a democracy instead.
Your task is to write a program, which takes the information about the cities on the map as inputs, and outputs for each city one of the three outcomes:
• It is the capital of a kindgom.
• It is the capital of a democracy.
• It obeys city as its capital.
输入格式
The input is read from a text file named countries.in
.
The first line consists of one integer , the number of cities.
The following lines give the information on the cities, each city as its own line.
Line gives the information on city as the three integers which are separated by single space characters.
输出格式
The output is written into a text file named countries.out
.
The output consists of lines, where line i consists of the outcome for city :
• The character K
if city is the capital of a kingdom.
• The character D
if city is the capital of a democracy.
• The number of the city which city obeys as its capital if city had to surrender.
5
2 5 14
2 3 2
3 2 7
1 1 2
2 1 3
K
D
K
3
3
数据规模与约定
对于 的数据,,。