欢迎光临散文网 会员登陆 & 注册

CF 1713A - Traveling Salesman Problem

2023-06-27 12:45 作者:您是打尖儿还是住店呢  | 我要投稿

You are living on an infinite plane with the Cartesian coordinate system on it. In one move you can go to any of the four adjacent points (left, right, up, down).


More formally, if you are standing at the point (x,y), you can:

go left, and move to (x−1,y), or go right, and move to (x+1,y)

, or go up, and move to (x,y+1), or go down, and move to (x,y−1).

There are n boxes on this plane. The i-th box has coordinates (xi,yi). It is guaranteed that the boxes are either on the x-axis or the y-axis. That is, either xi=0 or yi=0.

You can collect a box if you and the box are at the same point. Find the minimum number of moves you have to perform to collect all of these boxes if you have to start and finish at the point (0,0)

----------------------------------------------------------

你生活在一个无限平面上,上面有笛卡尔坐标系。 您可以一次移动到四个相邻点(左、右、上、下)中的任何一个。


更正式地说,如果您站在 (x,y) 点,您可以:

向左移动,移动到 (x−1,y),或者向右移动,移动到 (x+1,y)

,或者向上,移动到 (x,y+1),或者向下,移动到 (x,y−1)。

这架飞机上有n个盒子。 第 i 个框的坐标为 (xi,yi)。 确保盒子位于 x 轴或 y 轴上。 即,xi=0 或yi=0。

如果你和盒子在同一点,你就可以收集一个盒子。 如果您必须在点 (0,0) 开始和结束,请求出收集所有这些盒子所需执行的最少移动次数。

---------------------------------------------

其实就是求x坐标轴的最大最小值跟y坐标轴的最大最小值即可;


CF 1713A - Traveling Salesman Problem的评论 (共 条)

分享到微博请遵守国家法律