当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

BZOJ1351:[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 i is in a distinct location with coordinates (xi, yi) on the map. The city has also a number si of soldiers in it under the command of a general.
The influence city i exerts to another location (x, y) is computed as si divided by the squared distance between it and (x, y). It is as if the mass of soldiers in city i exerted a gravitational pull to all map locations around it. City i is threatened by another city j if the influence exerted by city j on the location (xi, yi) of city i exceeds its number of soldiers si: then city j can dispatch enough soldiers to overpower all the soldiers defending city i. If city i is not threatened by any other city j, 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 j threatening city i exerts strictly more influence on its location (xi, yi) than any other city k, then the citizens of city i have no choice: city I must surrender to city j. Henceforth city i must obey the same capital as city j obeys; however, the si soldiers in city i do not join the army of city j or the capital. Otherwise city i is saved by mutual distrust of the equally threatening cities j and k: If one of them would attack and overpower city i, then the other would in turn attack and overpower the battle-weary first attackers. However, the citizens of city i 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 i one of the three outcomes:
• It is the capital of a kindgom.
• It is the capital of a democracy.
• It obeys city j as its capital.
输入解释
The input is read from a text file named countries.in. The first line consists of one integer 1 ≤ n ≤ 1000, the number of cities. The following n lines give the information on the n cities, each city as its own line. Line i + 1 gives the information on city i as the three integers xi, yi, si which are separated by single space characters. All these numbers are in range 0 ≤ xi, yi, si ≤ 1000.
输出解释
The output is written into a text file named countries.out. The output consists of n lines, where line i consists of the outcome for city i:
• The character K if city i is the capital of a kingdom.
• The character D if city i is the capital of a democracy.
• The number 1 ≤ j ≤ n of the city which city i obeys as its capital if city i had to surrender.
输入样例
5
2 5 14
2 3 2
3 2 7
1 1 2
2 1 3
输出样例
K
D
K
3
3

该题目包含在题集 大视野(八中)OJ 中

题目来源 BZOJ 1351

源链接: LOCAL-BZOJ1351

共提交 0 次

通过率 --%
时间上限 内存上限
5000 MS 162 MB