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

建议使用的浏览器:

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

5330:Route Statistics

题目描述
JRY is so rich that he creates an $m$ demensional space and $n$ sight spots inside. Because of special technical problem, all the coordinates are integers between $[0,2]$. The roads in this space are all parallel to the axis, so the distance between two sight spots is their Manhattan distance. More specifically, if the coordinate of one sight spot is $(x_1,x_2,\ldots,x_m)$, and that of another sight spot is $(y_1,y_2,\ldots,y_m)$, then their distance is $\sum_{i=1}^{m}|x_i-y_i|$. JRY wants to establish some bus routes between two sight spots, so he needs to do some research first. For you, the problem is to find the total number of pairs $(x,y)$ for each $k$, that the distance between $(x,y)$ is $k$. Please be aware: 1. $(x,x)$ does not count; 2. $(x,y)$ and $(y, x)$ are identical, so that it is only one pair; 3. different sight spots may have same coordinates.
输入解释
The first line of the input is a single integer $T\ (T = 11)$, indicating the number of testcases.

For each testcase, the first line contains two integers $n$ and $m$. Each of the following $n$ lines contains one string of length $m$, which consists three types of characters $0, 1, 2$, and the $j$-th character of the $i$-th string means the $j$-th coordinate of the $i$-th spot. It is guaranteed that the $m$ of the $i$-th testcase is $i$, and for all testcases $\sum n \le 300000$.
输出解释
For each testcase, print $2m+1$ lines. The single number in the $i$-th line of the output indicates the number of pairs of sight spots with distance $i-1$
输入样例
2
2 1
0
1
6 2
00
01
10
11
02
00
输出样例
0
1
0
1
7
6
1
0
来自杭电HDUOJ的附加信息
Author XJZX
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5330

最后修改于 2020-10-25T23:21:46+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 262144/262144K(Java/Others)