|
| 1 | +<html><body bgcolor="#000000" text="#ffffff"><table><tr><td colspan="2"><h3>Problem Statement</h3></td></tr><tr><td>    </td><td><p> |
| 2 | +A simple way to blur an image is to replace each pixel |
| 3 | +with the average of it and its neighboring pixels. |
| 4 | +The value of each pixel in the blurred image is computed |
| 5 | +by adding the values of the 3x3 region centered at the |
| 6 | +corresponding pixel of the original image, and dividing |
| 7 | +by 9. |
| 8 | +</p> |
| 9 | +<p> |
| 10 | +When computing the value of pixels on the border, the 3x3 region will |
| 11 | +fall partially outside of the original image. Assume that |
| 12 | +pixels outside of the original image are black. |
| 13 | +</p> |
| 14 | + |
| 15 | +<p> |
| 16 | +For example, given the following original image: |
| 17 | +</p> |
| 18 | + |
| 19 | +<center> |
| 20 | +<img src="http://www.topcoder.com/contest/problem/UnBlur/unblur_fig1a.gif"></img> |
| 21 | +</center> |
| 22 | + |
| 23 | +<p> |
| 24 | +the algorithm described above results in the following blurred image: |
| 25 | +</p> |
| 26 | + |
| 27 | +<center> |
| 28 | +<img src="http://www.topcoder.com/contest/problem/UnBlur/unblur_fig1b.gif"></img> |
| 29 | +</center> |
| 30 | + |
| 31 | +<p> |
| 32 | +Write a method that will, given a blurred image, return the original image. |
| 33 | +The original image will contain only black and white pixels. |
| 34 | +All pixels on the top and bottom rows and left and right |
| 35 | +columns of the original image will be black. |
| 36 | +All values of the blurred image will therefore be: 0 (black), 1/9, 2/9, |
| 37 | +3/9, 4/9, 5/9, 6/9, 7/9, 8/9, or 9/9 (white). |
| 38 | +</p> |
| 39 | +<p> |
| 40 | +The blurred image will be given as a vector <string>. |
| 41 | +Each character in the blurred image will be a character between |
| 42 | +'0' and '9', inclusive, giving the value of that pixel multiplied |
| 43 | +by nine. |
| 44 | +For example, the blurred image above would be given as: |
| 45 | +</p> |
| 46 | + |
| 47 | +<pre> |
| 48 | + |
| 49 | +{ "1233321000000000123332100000000000000000000", |
| 50 | + "1244422233222332334343323322232112332223321", |
| 51 | + "1255523344343443545343434434343233432334432", |
| 52 | + "0033303455465775633011445546454355753457753", |
| 53 | + "0033303333364543533011433336333364521346542", |
| 54 | + "0033303455464532445343545546454355753446542", |
| 55 | + "0022202344342200234343434434343233432323221", |
| 56 | + "0011101233221100123332223322232112332211111" } |
| 57 | +</pre> |
| 58 | + |
| 59 | +<p> |
| 60 | +Return the original image as a vector <string>. |
| 61 | +For each pixel in the original image, return a '.' |
| 62 | +if it is black and '#' if it is white. |
| 63 | +For example, the original image for the example |
| 64 | +above would be returned as: |
| 65 | +</p> |
| 66 | + |
| 67 | +<pre> |
| 68 | +{ "...........................................", |
| 69 | + ".#####...........#####.....................", |
| 70 | + "...#...####.####.#...#.####.###..####.####.", |
| 71 | + "...#...#..#.#..#.#.....#..#.#..#.#....#..#.", |
| 72 | + "...#...#..#.####.#.....#..#.#..#.###..####.", |
| 73 | + "...#...#..#.#....#...#.#..#.#..#.#....#.#..", |
| 74 | + "...#...####.#....#####.####.###..####.#..#.", |
| 75 | + "..........................................." } |
| 76 | +</pre> |
| 77 | +</td></tr><tr><td colspan="2"><h3>Definition</h3></td></tr><tr><td>    </td><td><table><tr><td>Class:</td><td>Unblur</td></tr><tr><td>Method:</td><td>original</td></tr><tr><td>Parameters:</td><td>vector <string></td></tr><tr><td>Returns:</td><td>vector <string></td></tr><tr><td>Method signature:</td><td>vector <string> original(vector <string> blurred)</td></tr><tr><td colspan="2">(be sure your method is public)</td></tr></table></td></tr><tr><td colspan="2"><h3>Limits</h3></td></tr><tr><td>    </td><td><table><tr><td>Time limit (s):</td><td>2.000</td></tr><tr><td>Memory limit (MB):</td><td>64</td></tr></table></td></tr><tr><td colspan="2"><h3>Constraints</h3></td></tr><tr><td align="center" valign="top">-</td><td><b>blurred</b> will contain between 1 and 50 elements, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td>Each element of <b>blurred</b> will have a length between 1 and 50, inclusive, and contain only characters between '0' and '9', inclusive.</td></tr><tr><td align="center" valign="top">-</td><td>Each element of <b>blurred</b> will have the same length.</td></tr><tr><td align="center" valign="top">-</td><td><b>blurred</b> will be the result of blurring a black and white image.</td></tr><tr><td colspan="2"><h3>Examples</h3></td></tr><tr><td align="center" nowrap="true">0)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{ "1221", |
| 78 | + "1221", |
| 79 | + "1221" }</pre></td></tr></table></td></tr><tr><td><pre>Returns: { "....", ".##.", "...." }</pre></td></tr><tr><td><table><tr><td colspan="2"><p> |
| 80 | +All pixels in the center two columns are adjacent to two white pixels in the source image. The remaining pixels are adjacent to only one. |
| 81 | +</p> |
| 82 | +</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{ "00000", |
| 83 | + "00000", |
| 84 | + "00000", |
| 85 | + "00000" }</pre></td></tr></table></td></tr><tr><td><pre>Returns: { ".....", ".....", ".....", "....." }</pre></td></tr><tr><td><table><tr><td colspan="2">A solid black image blurs to all zeros.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{ "0011212121100", |
| 86 | + "0123333333210", |
| 87 | + "0123333333210", |
| 88 | + "1233333333321", |
| 89 | + "1233333333321", |
| 90 | + "1233333333321", |
| 91 | + "0112121212110" } </pre></td></tr></table></td></tr><tr><td><pre>Returns: |
| 92 | +{ ".............", |
| 93 | + "...#.#.#.#...", |
| 94 | + "..#.#.#.#.#..", |
| 95 | + ".............", |
| 96 | + ".#.#.#.#.#.#.", |
| 97 | + "..#.#.#.#.#..", |
| 98 | + "............." }</pre></td></tr><tr><td><table><tr><td colspan="2"><p> |
| 99 | +original: |
| 100 | +</p> |
| 101 | +<img src="http://graphics.lcs.mit.edu/~legakis/TC/unblur_fig3a.gif"></img> |
| 102 | +<p> |
| 103 | +blurred: |
| 104 | +</p> |
| 105 | +<img src="http://graphics.lcs.mit.edu/~legakis/TC/unblur_fig3b.gif"></img> |
| 106 | +</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">3)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{ "1233321000000000123332100000000000000000000", |
| 107 | + "1244422233222332334343323322232112332223321", |
| 108 | + "1255523344343443545343434434343233432334432", |
| 109 | + "0033303455465775633011445546454355753457753", |
| 110 | + "0033303333364543533011433336333364521346542", |
| 111 | + "0033303455464532445343545546454355753446542", |
| 112 | + "0022202344342200234343434434343233432323221", |
| 113 | + "0011101233221100123332223322232112332211111" } </pre></td></tr></table></td></tr><tr><td><pre>Returns: |
| 114 | +{ "...........................................", |
| 115 | + ".#####...........#####.....................", |
| 116 | + "...#...####.####.#...#.####.###..####.####.", |
| 117 | + "...#...#..#.#..#.#.....#..#.#..#.#....#..#.", |
| 118 | + "...#...#..#.####.#.....#..#.#..#.###..####.", |
| 119 | + "...#...#..#.#....#...#.#..#.#..#.#....#.#..", |
| 120 | + "...#...####.#....#####.####.###..####.#..#.", |
| 121 | + "..........................................." }</pre></td></tr><tr><td><table><tr><td colspan="2">This is the example from the problem statement.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">4)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{ "0000123210000", |
| 122 | + "0012456542100", |
| 123 | + "0135789875310", |
| 124 | + "0258988898520", |
| 125 | + "1479865689741", |
| 126 | + "2589742479852", |
| 127 | + "2589742479852", |
| 128 | + "1479865689741", |
| 129 | + "0258988898520", |
| 130 | + "0135789875310", |
| 131 | + "0012456542100", |
| 132 | + "0000123210000" } |
| 133 | +</pre></td></tr></table></td></tr><tr><td><pre>Returns: |
| 134 | +{ ".............", |
| 135 | + ".....###.....", |
| 136 | + "...#######...", |
| 137 | + "..#########..", |
| 138 | + "..####.####..", |
| 139 | + ".####...####.", |
| 140 | + ".####...####.", |
| 141 | + "..####.####..", |
| 142 | + "..#########..", |
| 143 | + "...#######...", |
| 144 | + ".....###.....", |
| 145 | + "............." }</pre></td></tr><tr><td><table><tr><td colspan="2"><p> |
| 146 | +original: |
| 147 | +</p> |
| 148 | +<img src="http://graphics.lcs.mit.edu/~legakis/TC/unblur_fig4a.gif"></img> |
| 149 | +<p> |
| 150 | +blurred: |
| 151 | +</p> |
| 152 | +<img src="http://graphics.lcs.mit.edu/~legakis/TC/unblur_fig4b.gif"></img></td></tr></table></td></tr></table></td></tr></table><p>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. </p></body></html> |
0 commit comments