CF1425D.Danger of Mad Snakes
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mr. Chanek The Ninja is one day tasked with a mission to handle mad snakes that are attacking a site. Now, Mr. Chanek already arrived at the hills where the destination is right below these hills. The mission area can be divided into a grid of size 1000×1000 squares. There are N mad snakes on the site, the i'th mad snake is located on square (Xi,Yi) and has a danger level Bi.
Mr. Chanek is going to use the Shadow Clone Jutsu and Rasengan that he learned from Lord Seventh to complete this mission. His attack strategy is as follows:
- Mr. Chanek is going to make M clones.
- Each clone will choose a mad snake as the attack target. Each clone must pick a different mad snake to attack.
- All clones jump off the hills and attack their respective chosen target at once with Rasengan of radius R. If the mad snake at square (X,Y) is attacked with a direct Rasengan, it and all mad snakes at squares (X′,Y′) where max(∣X′−X∣,∣Y′−Y∣)≤R will die.
- The real Mr. Chanek will calculate the score of this attack. The score is defined as the square of the sum of the danger levels of all the killed snakes.
Now Mr. Chanek is curious, what is the sum of scores for every possible attack strategy? Because this number can be huge, Mr. Chanek only needs the output modulo 109+7.
忍者陈克先生某天接到一项任务,负责处理正在袭击某处的狂蛇。目前,陈克先生已抵达目的地正上方的山丘。任务区域可划分为一个 1000×1000 的方格网格。现场共有 N 条狂蛇,第 i 条狂蛇位于方格 (Xi,Yi) 处,其危险等级为 Bi。
陈克先生将使用他从第七代火影那里学来的“影分身之术”与“螺旋丸”来完成此项任务。他的攻击策略如下:
- 陈克先生将制造 M 个分身。
- 每个分身须各自选择一条狂蛇作为攻击目标;每个分身所选的目标必须互不相同。
- 所有分身同时从山丘跃下,以半径为 R 的螺旋丸攻击各自选定的目标。若位于方格 (X,Y) 的狂蛇遭到螺旋丸直接攻击,则该蛇以及所有位于方格 (X′,Y′) 处、满足 max(∣X′−X∣,∣Y′−Y∣)≤R 的狂蛇均会被消灭。
- 真身陈克先生将计算此次攻击的得分。得分定义为:所有被消灭狂蛇的危险等级之和的平方。
现在陈克先生很好奇:对所有可能的攻击策略,其得分之和是多少?由于该数值可能极大,陈克先生仅需输出结果对 109+7 取模后的值。
输入格式
The first line contains three integers N M R (1≤M≤N≤2⋅103,0≤R<103), the number of mad snakes, the number of clones, and the radius of the Rasengan.
The next N lines each contains three integers, Xi, Yi, dan Bi (1≤Xi,Yi≤103,1≤Bi≤106). It is guaranteed that no two mad snakes occupy the same square.
第一行包含三个整数 N、M 和 R(1≤M≤N≤2⋅103,0≤R<103),分别表示狂蛇的数量、克隆体的数量以及螺旋丸的半径。
接下来的 N 行每行包含三个整数 Xi、Yi 和 Bi(1≤Xi,Yi≤103,1≤Bi≤106)。保证任意两条狂蛇不会占据同一格子。
输出格式
A line with an integer that denotes the sum of scores for every possible attack strategy.
一个整数,表示所有可能攻击策略的得分总和。
输入输出样例
输入#1
4 2 1 1 1 10 2 2 20 2 3 30 5 2 40
输出#1
33800
说明/提示
Here is the illustration of all six possible attack strategies. The circles denote the chosen mad snakes, and the blue squares denote the region of the Rasengan:

So, the total score of all attacks is: 3.600+3.600+4.900+3.600+10.000+8.100=33.800.
以下是全部六种可能的攻击策略示意图。圆圈表示所选的狂蛇,蓝色正方形表示螺旋丸的作用区域:

因此,所有攻击的总得分为:3.600+3.600+4.900+3.600+10.000+8.100=33.800。
输入解题思路,AI测评打分。不知道怎么写?