#P7639. [BalticOI 2006] COUNTRIES (Day 1)
[BalticOI 2006] COUNTRIES (Day 1)
Description
Consider a 2D map of a region. There are cities on this map. Each city has a unique coordinate . Each city has soldiers under the command of a general.
The intimidation (threat) that city exerts on another position equals divided by the square of the distance between it and . You can think of it as the many soldiers in city exerting intimidation on all nearby positions on the map. If the intimidation from city to city at exceeds its number of soldiers (meaning city can send enough soldiers to subdue the soldiers defending city ), then city is threatened by city . If city is not threatened by any other city , then the grateful citizens will elect their invincible general as their king, and make their city the capital of his kingdom.
On the other hand, if some city threatens city at more than another city does, then the residents of city have no choice: city can only surrender to city . From then on, city must obey the capital that city obeys; however, the soldiers of city do not join the army of city or its capital. In addition, city can be saved because two cities and that threaten it equally will guard against each other: if one city attacks and conquers city , the other will come to attack and defeat the attacker’s soldiers, who have just fought and are exhausted. But in this case, the residents of city will no longer elect their general as king, because he failed in his duty to protect the city from threats. Therefore, they must make their city the capital of a democratic country.
Your task is to write a program that takes the map’s city information as input, and for each city outputs one of the following three results:
- It is the capital of a kingdom.
- It is the capital of a democratic country.
- It obeys city as its capital.
Input Format
The first line contains an integer , the number of cities. The next lines give the information of these cities. Line contains three integers , , describing city , separated by single spaces.
Output Format
Output consists of lines. Line contains the result for city :
- The letter means city is the capital of a kingdom.
- The letter means city is the capital of a democratic country.
- A positive integer means city must surrender and obey city as its capital.
5
2 5 14
2 3 2
3 2 7
1 1 2
2 1 3
K
D
K
3
3
Hint
Constraints
For of the testdata, , , .
Sample Explanation
Consider the following map, where each point represents a city, and the number above it is the number of soldiers:

That is, city at position is the capital of a kingdom, and it also includes city at position and city at position . On the other hand, city at position forms a kingdom by itself, and city at position forms a democratic country by itself.
Problem Notes
From Day 1: Countries of the Baltic Olympiad in Informatics 2006.
Translated and organized by @求学的企鹅.
Translated by ChatGPT 5
京公网安备 11011102002149号