{"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\u003eWe are being attacked on a map represented by a rectangular grid of R×S squares. The attackers are barefoot robbers, and we use small cannons on small wooden towers to defend ourselves.\u003c/p\u003e\r\n\u003cp\u003eEach tower is equipped with \u003cstrong\u003etwo cannons\u003c/strong\u003e, placed to fire in a 90 degree angle. More precisely, cannons on one tower can be set to fire in one of the following four configurations:\u003c/p\u003e\r\n\u003col\u003e\r\n\u003cli\u003efire left and down;\u003c/li\u003e\r\n\u003cli\u003efire down and right;\u003c/li\u003e\r\n\u003cli\u003efire right and up;\u003c/li\u003e\r\n\u003cli\u003efire up and left.\u003c/li\u003e\r\n\u003c/ol\u003e\r\n\u003cp\u003eA cannon ball that hits the attacker \u003cstrong\u003edestroys him and continues to fly\u003c/strong\u003e in the same direction. A cannon ball which hits a castle stops and does no damage to the castle (because castles are big and strong). But, when a cannon ball hits a tower, it destroys it (because towers are small and fragile).\u003c/p\u003e\r\n\u003cp\u003eWe want to turn the cannons on the towers so that, when we fire exactly one shot from \u003cstrong\u003eevery cannon\u003c/strong\u003e, \u003cstrong\u003ewe destroy all the attackers\u003c/strong\u003e, and \u003cstrong\u003eall our towers remain undamaged.\u003c/strong\u003e\u003c/p\u003e\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe first line contains two integers R and S (1 ≤ R, S ≤ 100), the dimensions of the map.\u003c/p\u003e\r\n\u003cp\u003eThe next R lines contain S characters each, the map.\u003c/p\u003e\r\n\u003cp\u003eEach character on the map can be the uppercase letter \u0027\u003ctt\u003eT\u003c/tt\u003e\u0027 (tower), lowercase letter \u0027\u003ctt\u003en\u003c/tt\u003e\u0027 (attacker), the character \u0027\u003ctt\u003e#\u003c/tt\u003e\u0027 (castle) or the character \u0027\u003ctt\u003e.\u003c/tt\u003e\u0027 (empty).\u003c/p\u003e\r\n\u003cp\u003e\u003cstrong\u003eNote:\u003c/strong\u003e There will always be a solution, although not necessarily unique.\u003c/p\u003e\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eOutput the map in the same format as in the input, replacing \u0027\u003ctt\u003eT\u003c/tt\u003e\u0027 characters with the orientations of the cannons – each tower should be replaced with one of the digits \u0027\u003ctt\u003e1\u003c/tt\u003e\u0027, \u0027\u003ctt\u003e2\u003c/tt\u003e\u0027, \u0027\u003ctt\u003e3\u003c/tt\u003e\u0027 or \u0027\u003ctt\u003e4\u003c/tt\u003e\u0027, corresponding to the four orientations as described above.\u003c/p\u003e\r\n\u003ch3\u003eExamples\u003c/h3\u003e\r\n\u003ctable style\u003d\"width: 100%;\" border\u003d\"0\"\u003e\r\n\u003ccolgroup\u003e\u003ccol align\u003d\"left\" width\u003d\"33%\"\u003e\u003c/colgroup\u003e \u003ccolgroup\u003e\u003ccol align\u003d\"left\" width\u003d\"33%\"\u003e\u003c/colgroup\u003e \u003ccolgroup\u003e\u003ccol align\u003d\"left\" width\u003d\"33%\"\u003e\u003c/colgroup\u003e \r\n\u003ctbody\u003e\r\n\u003ctr\u003e\r\n\u003ctd valign\u003d\"top\"\u003e\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\u003e9 13\r\n.............\r\n...........n.\r\n.n.T..nnnn#..\r\n.............\r\n.T#n..n....T.\r\n.............\r\n.n.T..T....n.\r\n.............\r\n......n......\r\n\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e.............\r\n...........n.\r\n.n.3..nnnn#..\r\n.............\r\n.4#n..n....4.\r\n.............\r\n.n.1..2....n.\r\n.............\r\n......n......\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\u003c/td\u003e\r\n\u003ctd valign\u003d\"top\"\u003e\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\u003e5 9\r\n.n..T..n.\r\n.T..n....\r\n.n..#..n.\r\n....n..T.\r\n.n..T..n.\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e.n..4..n.\r\n.2..n....\r\n.n..#..n.\r\n....n..4.\r\n.n..3..n.\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\u003c/td\u003e\r\n\u003ctd valign\u003d\"top\"\u003e\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\u003e9 8\r\nn.Tnnnnn\r\nnnnnnnTn\r\nnTnnnnnn\r\nnnnnTnnn\r\nTnnnnnnn\r\n..#nnTnn\r\nnnnnnnnT\r\nnnnTn.n.\r\n.nTnnnnn\r\n\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003en.3nnnnn\r\nnnnnnn1n\r\nn2nnnnnn\r\nnnnn1nnn\r\n3nnnnnnn\r\n..#nn4nn\r\nnnnnnnn4\r\nnnn4n.n.\r\n.n3nnnnn\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\u003c/td\u003e\r\n\u003c/tr\u003e\r\n\u003c/tbody\u003e\r\n\u003c/table\u003e\n\u003c/div\u003e"}}]}