CF201B.Guess That Car!
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A widely known among some people Belarusian sport programmer Yura possesses lots of information about cars. That is why he has been invited to participate in a game show called "Guess That Car!".
The game show takes place on a giant parking lot, which is 4_n_ meters long from north to south and 4_m_ meters wide from west to east. The lot has n + 1 dividing lines drawn from west to east and m + 1 dividing lines drawn from north to south, which divide the parking lot into n·m 4 by 4 meter squares. There is a car parked strictly inside each square. The dividing lines are numbered from 0 to n from north to south and from 0 to m from west to east. Each square has coordinates (i, j) so that the square in the north-west corner has coordinates (1, 1) and the square in the south-east corner has coordinates (n, m). See the picture in the notes for clarifications.
Before the game show the organizers offer Yura to occupy any of the (n + 1)·(m + 1) intersection points of the dividing lines. After that he can start guessing the cars. After Yura chooses a point, he will be prohibited to move along the parking lot before the end of the game show. As Yura is a car expert, he will always guess all cars he is offered, it's just a matter of time. Yura knows that to guess each car he needs to spend time equal to the square of the euclidean distance between his point and the center of the square with this car, multiplied by some coefficient characterizing the machine's "rarity" (the rarer the car is, the harder it is to guess it). More formally, guessing a car with "rarity" c placed in a square whose center is at distance d from Yura takes c·_d_2 seconds. The time Yura spends on turning his head can be neglected.
It just so happened that Yura knows the "rarity" of each car on the parking lot in advance. Help him choose his point so that the total time of guessing all cars is the smallest possible.
一位在某些人群中广为人知的白俄罗斯体育程序员尤拉(Yura)掌握着大量关于汽车的信息。因此,他被邀请参加一档名为“猜猜那辆车!”的游戏节目。
该节目在一个巨大的停车场举行,该停车场南北方向长 4n 米,东西方向宽 4m 米。场内画有 n+1 条自西向东延伸的分隔线,以及 m+1 条自北向南延伸的分隔线,从而将整个停车场划分为 n⋅m 个 4 米 × 4 米的正方形区域。每个正方形区域内严格停放着一辆汽车。这些分隔线按如下方式编号:自北向南编号为 0 至 n,自西向东编号为 0 至 m。每个正方形具有坐标 (i,j),其中西北角的正方形坐标为 (1,1),东南角的正方形坐标为 (n,m)。详见注释中的图示以作澄清。
在节目开始前,主办方允许尤拉任选这 (n+1)⋅(m+1) 个分隔线交点中的任意一个作为自己的站位点。选定后,在节目结束前他不得在停车场内移动。由于尤拉是汽车专家,他总能最终猜出所有向他展示的车辆,只是所需时间长短不同而已。尤拉知道:对每辆汽车,他所需的猜测时间等于他所在位置到该车所在正方形中心的欧几里得距离的平方,再乘以一个表征该车“稀有度”的系数(车越稀有,越难猜中)。更准确地说,若一辆“稀有度”为 c 的汽车停放在其中心距尤拉位置为 d 的正方形内,则猜中它需要 c⋅d2 秒。尤拉转头所花费的时间可忽略不计。
巧合的是,尤拉事先已知晓停车场上每一辆车的“稀有度”。请帮他选择一个最优站位点,使得他猜中所有汽车所需的总时间最小。
输入格式
The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the sizes of the parking lot. Each of the next n lines contains m integers: the j-th number in the i-th line describes the "rarity" c__ij (0 ≤ c__ij ≤ 100000) of the car that is located in the square with coordinates (i, j).
第一行包含两个整数 n 和 m(1≤n,m≤1000)——表示停车场的尺寸。接下来的 n 行中,每行包含 m 个整数:第 i 行中的第 j 个数描述了位于坐标为 (i,j) 的方格中的汽车的“稀有度” cij(0≤cij≤100000)。
输出格式
In the first line print the minimum total time Yura needs to guess all offered cars. In the second line print two numbers l__i and l__j (0 ≤ l__i ≤ n, 0 ≤ l__j ≤ m) — the numbers of dividing lines that form a junction that Yura should choose to stand on at the beginning of the game show. If there are multiple optimal starting points, print the point with smaller l__i. If there are still multiple such points, print the point with smaller l__j.
Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
第一行输出尤拉猜出所有提供的汽车所需的最少总时间。
第二行输出两个数 li 和 lj(0 ≤ li ≤ n,0 ≤ lj ≤ m)——尤拉应在游戏节目开始时所站的十字路口所对应的两条分界线的编号。若存在多个最优起始点,输出其中 li 更小的点;若仍存在多个这样的点,则输出其中 lj 更小的点。
请注意:在 C++ 中,请勿使用 %lld 说明符读写 64 位整数。推荐使用 cin、cout 流,或 %I64d 说明符。
输入输出样例
输入#1
2 3 3 4 5 3 9 1
输出#1
392 1 1
输入#2
3 4 1 0 0 0 0 0 3 0 0 0 5 5
输出#2
240 2 3
说明/提示
In the first test case the total time of guessing all cars is equal to 3·8 + 3·8 + 4·8 + 9·8 + 5·40 + 1·40 = 392.
The coordinate system of the field:

在第一个测试用例中,猜测所有汽车的总时间为 3⋅8 + 3⋅8 + 4⋅8 + 9⋅8 + 5⋅40 + 1⋅40 = 392。
场地的坐标系:

输入解题思路,AI测评打分。不知道怎么写?