{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cp\u003eDee Siduous is a botanist who specializes in trees. A lot of\n her research has to do with the formation of tree rings, and\n what they say about the growing conditions over the tree’s\n lifetime. She has a certain theory and wants to run some\n simulations to see if it holds up to the evidence gathered in\n the field.\u003c/p\u003e\n\n \u003cp\u003eOne thing that needs to be done is to determine the expected\n number of rings given the outline of a tree. Dee has decided to\n model a cross section of a tree on a two dimenional grid, with\n the interior of the tree represented by a closed polygon of\n grid squares. Given this set of squares, she assigns rings from\n the outer parts of the tree to the inner as follows: calling\n the non-tree grid squares “ring \u003cspan class\u003d\"tex2jax_process\"\u003e$0$\u003c/span\u003e”, each ring \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e is made up of all those grid\n squares that have at least one ring \u003cspan class\u003d\"tex2jax_process\"\u003e$(n-1)$\u003c/span\u003e square as a neighbor (where\n neighboring squares are those that share an edge).\u003c/p\u003e\n\n \u003cp\u003eAn example of this is shown in the figure below.\u003c/p\u003e\n\n \u003ccenter\u003e\n \u003cimg src\u003d\"CDN_BASE_URL/0b000267670e4db95fb56a57e555e457?v\u003d1715285604\" alt\u003d\"\\includegraphics[width\u003d0.60\\textwidth ]{ring}\" style\u003d\"width:60.00%\"\u003e\u003cbr\u003e\n Figure D.1\n \u003c/center\u003e\n\n \u003cp\u003eMost of Dee’s models have been drawn on graph paper, and she\n has come to you to write a program to do this automatically for\n her. This way she’ll use less paper and save some \u003cspan class\u003d\"tex2jax_process\"\u003e$\\ldots $\u003c/span\u003e well, you know.\u003c/p\u003e\n\n \u003ch2\u003eInput\u003c/h2\u003e\n\n \u003cp\u003eThe input will start with a line containing two positive\n integers \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$m$\u003c/span\u003e specifying the number of rows and\n columns in the tree grid, where \u003cspan class\u003d\"tex2jax_process\"\u003e$n, m \\leq 100$\u003c/span\u003e. After this will be\n \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e rows containing\n \u003cspan class\u003d\"tex2jax_process\"\u003e$m$\u003c/span\u003e characters each. These\n characters will be either ‘T’ indicating a tree grid square, or\n ‘.’.\u003cbr\u003e\u003c/p\u003e\n\n \u003ch2\u003eOutput\u003c/h2\u003e\n\n \u003cp\u003eOutput a grid with the ring numbers. If the number of rings\n is less than 10, use two characters for each grid square;\n otherwise use three characters for each grid square. Right\n justify all ring numbers in the grid squares, and use ‘.’ to\n fill in the remaining characters.\u003c/p\u003e\n\n \u003cp\u003eIf a row or column does not contain a ring number it should\n still be output, filled entirely with ‘.’s.\u003c/p\u003e\n\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\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\u003e6 6\n.TT...\nTTTT..\nTTTTT.\nTTTTT.\nTTTTTT\n..T...\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e...1.1......\n.1.2.2.1....\n.1.2.3.2.1..\n.1.2.3.2.1..\n.1.1.2.1.1.1\n.....1......\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n\n \u003ch2\u003eSample 2\u003c/h2\u003e\u003cbody\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\u003e3 4\nTT..\nTT..\n....\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e.1.1....\n.1.1....\n........\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}