{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003e\r\nThere is given a rectangular bitmap of size \u003ci\u003en*m\u003c/i\u003e. Each pixel of the bitmap is either white or black, but at least one is white. The pixel in\r\n\u003ci\u003ei\u003c/i\u003e-th line and \u003ci\u003ej\u003c/i\u003e-th column is called the pixel (\u003ci\u003ei,j\u003c/i\u003e). The distance between two pixels\r\n\u003cb\u003e p\u003csub\u003e1\u003c/sub\u003e\u003c/b\u003e\u003d(\u003ci\u003ei\u003csub\u003e1\u003c/sub\u003e,j\u003csub\u003e1\u003c/sub\u003e\u003c/i\u003e) and \u003cb\u003ep\u003csub\u003e2\u003c/sub\u003e\u003c/b\u003e\u003d(\u003ci\u003ei\u003csub\u003e2\u003c/sub\u003e,j\u003csub\u003e2\u003c/sub\u003e\u003c/i\u003e) is defined as:\r\n\u003c/p\u003e\r\n\r\n\u003cp\u003e\u003c/p\u003e\u003ccenter\u003e\r\nd(\u003cb\u003ep\u003csub\u003e1\u003c/sub\u003e\u003c/b\u003e,\u003cb\u003ep\u003csub\u003e2\u003c/sub\u003e\u003c/b\u003e)\u003d|\u003ci\u003ei\u003csub\u003e1\u003c/sub\u003e-i\u003csub\u003e2\u003c/sub\u003e\u003c/i\u003e|+|\u003ci\u003ej\u003csub\u003e1\u003c/sub\u003e-j\u003csub\u003e2\u003c/sub\u003e\u003c/i\u003e|.\r\n\u003c/center\u003e\u003cp\u003e\u003c/p\u003e\r\n\r\n\u003ch3\u003eTask\u003c/h3\u003e \r\n\r\n\u003cp\u003e\r\nWrite a program which:\r\n\u003c/p\u003e\u003cul\u003e \r\n \u003cli\u003ereads the description of the bitmap from the standard input,\r\n \u003c/li\u003e\u003cli\u003efor each pixel, computes the distance to the nearest white pixel,\r\n \u003c/li\u003e\u003cli\u003ewrites the results to the standard output. \r\n\u003c/li\u003e\u003c/ul\u003e \r\n\r\n\u003ch3\u003eInput\u003c/h3\u003e \r\n\r\n\u003cp\u003e\r\nThe number of test cases t is in the first line of input, then t test cases follow separated by an empty line.\r\n\r\nIn the first line of each test case there is a pair of integer numbers\u003ci\u003e\r\nn, m\u003c/i\u003e separated by a single space, \u003ci\u003e 1\u0026lt;\u003dn \u0026lt;\u003d182\u003c/i\u003e, \u003ci\u003e 1\u0026lt;\u003dm\u0026lt;\u003d182\u003c/i\u003e. In each of the following\r\n\u003ci\u003e n\u003c/i\u003e lines of the test case exactly one zero-one word of length\r\n\u003ci\u003e m,\u003c/i\u003e the description of one line of the bitmap, is written. On the \u003ci\u003ej\u003c/i\u003e-th position in the line\r\n(\u003ci\u003ei+1\u003c/i\u003e), \u003ci\u003e 1 \u0026lt;\u003d i \u0026lt;\u003d n\u003c/i\u003e, \u003ci\u003e 1 \u0026lt;\u003d j \u0026lt;\u003d m\u003c/i\u003e, is \u00271\u0027 if, and only if the pixel\r\n(\u003ci\u003ei,j\u003c/i\u003e) is\r\nwhite.\r\n\u003c/p\u003e\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\r\n\u003cp\u003e\r\nIn the \u003ci\u003ei\u003c/i\u003e-th line for each test case, \u003ci\u003e 1\u0026lt;\u003di\u0026lt;\u003dn\u003c/i\u003e, there\r\nshould be written\r\n\u003ci\u003e m\u003c/i\u003e integers f(\u003ci\u003ei,1\u003c/i\u003e),...,f(\u003ci\u003ei,m\u003c/i\u003e) separated by single spaces, where f(\u003ci\u003ei,j\u003c/i\u003e) is\r\nthe distance from the pixel\r\n(\u003ci\u003ei,j\u003c/i\u003e) to the nearest white\r\npixel.\r\n\u003c/p\u003e\r\n\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n3 4\r\n0001\r\n0011\r\n0110\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3 2 1 0\r\n2 1 0 0\r\n1 0 0 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e"}}]}