文件名称:01
介绍说明--下载内容均来自于网络,请自行研究使用
Descr iption
给定一个r * c的只包含0和1两个数字的矩阵,对于矩阵中任意一点(x,y),定义(x,y)的权为(x,y)到与此点曼哈顿距离最小的1的曼哈顿距离(如果mat[x][y] = 1,则(x,y)的权为0)。请求出对于给定01矩阵中所有点的权值之和。
所谓曼哈顿距离——两点在南北方向上的距离加上在东西方向上的距离,即D(I,J)=|XI-XJ|+|YI-YJ|。对于一个具有正南正北、正东正西方向规则布局的城镇街道,从一点到达另一点的距离正是在南北方向上旅行的距离加上在东西方向上旅行的距离因此曼哈顿距离又称为出租车距离,曼哈顿距离不是距离不变量,当坐标轴变动时,点间的距离就会不同。
Input
输入包含多组数据,每组数据第一行为两个整数r, c(0 < r, c < = 1000)。
接下来 r 行每行有 c 个整数,且保证只能为0或者1(保证矩阵中含有至少一个1)。
Output
对于每组数据,输出一个整数,此矩阵中每个点的权之和。
Sample Input
2 2
0 1
0 0
2 2
0 0
1 1
3 4
0 0 1 0
0 1 1 0
0 0 0 1
Sample Output
4
2
10-Descr iption
Given a r* c contains only numbers 0 and 1 matrix , the matrix for any point (x, y), the definition (x, y) has a weight of (x, y) to the minimum Manhattan distance to this point a Manhattan distance (if mat [x] [y] = 1, then (x, y) has a weight of 0 .) The right to request all the points for a given value of 01 and the matrix .
The so-called Manhattan distance- the distance between two points in the north-south direction with a distance in the east-west direction , i.e., D (I, J) = | XI-XJ |+ | YI-YJ |. For having a north south , east town street layout rules due west direction , from one point to another point is the distance to the north-south direction of travel distance plus the distance traveled east-west direction and therefore also known as Manhattan distance taxi distance, Manhattan distance is not a distance invariant , when changes in the axis , the distance between points will be different.
Input
Input contains multiple sets of data , each data of the
给定一个r * c的只包含0和1两个数字的矩阵,对于矩阵中任意一点(x,y),定义(x,y)的权为(x,y)到与此点曼哈顿距离最小的1的曼哈顿距离(如果mat[x][y] = 1,则(x,y)的权为0)。请求出对于给定01矩阵中所有点的权值之和。
所谓曼哈顿距离——两点在南北方向上的距离加上在东西方向上的距离,即D(I,J)=|XI-XJ|+|YI-YJ|。对于一个具有正南正北、正东正西方向规则布局的城镇街道,从一点到达另一点的距离正是在南北方向上旅行的距离加上在东西方向上旅行的距离因此曼哈顿距离又称为出租车距离,曼哈顿距离不是距离不变量,当坐标轴变动时,点间的距离就会不同。
Input
输入包含多组数据,每组数据第一行为两个整数r, c(0 < r, c < = 1000)。
接下来 r 行每行有 c 个整数,且保证只能为0或者1(保证矩阵中含有至少一个1)。
Output
对于每组数据,输出一个整数,此矩阵中每个点的权之和。
Sample Input
2 2
0 1
0 0
2 2
0 0
1 1
3 4
0 0 1 0
0 1 1 0
0 0 0 1
Sample Output
4
2
10-Descr iption
Given a r* c contains only numbers 0 and 1 matrix , the matrix for any point (x, y), the definition (x, y) has a weight of (x, y) to the minimum Manhattan distance to this point a Manhattan distance (if mat [x] [y] = 1, then (x, y) has a weight of 0 .) The right to request all the points for a given value of 01 and the matrix .
The so-called Manhattan distance- the distance between two points in the north-south direction with a distance in the east-west direction , i.e., D (I, J) = | XI-XJ |+ | YI-YJ |. For having a north south , east town street layout rules due west direction , from one point to another point is the distance to the north-south direction of travel distance plus the distance traveled east-west direction and therefore also known as Manhattan distance taxi distance, Manhattan distance is not a distance invariant , when changes in the axis , the distance between points will be different.
Input
Input contains multiple sets of data , each data of the
(系统自动生成,下载前可以参看下载内容)
下载文件列表
01.cpp