{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Time Limit: 1000 MS Memory Limit: 65536 K \n\u003chr\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003eSurrounding Game is a single-player game played on a n*m (2\u0026lt;\u003dn\u0026lt;\u003d20,2\u0026lt;\u003dm\u0026lt;\u003d20)rectangular grid of cells. Cells are considered adjacent if \u003cbr\u003ethey share a common side. (Hence, each cell has at most four adjacent cells. The cells on the sides and in the \u003cbr\u003e corners of the grid have fewer adjacent cells than the ones inside the grid.) \u003cbr\u003e\u003cbr\u003e\u003cbr\u003eThe game is played by placing stones into some of the cells. Each cell may only contain at most one stone. A cell \u003cbr\u003eis called dominated if at least one of the following two conditions holds:\u003cbr\u003e\u003cbr\u003e 1)The cell contains a stone. 2)All cells adjacent to the cell contain stones.\u003cbr\u003e\u003cbr\u003e\u003cbr\u003eEach cell of the grid contains two numbers, each from 0 to 61, inclusive: the cost of placing a stone into the cell, \u003cbr\u003eand the benefit from dominating the cell. At the end of the game, the overall score of the player is the sum of all \u003cbr\u003ebenefits minus the sum of all costs. \u003cbr\u003e\u003cbr\u003e\u003cbr\u003eYou are given the String[]s cost and benefit. The characters cost[i][j] and benefit[i][j] represent the two numbers\u003cbr\u003ewritten in the cell (i,j), using the following encoding: \u003cbr\u003e\u003cbr\u003e Characters \u00270\u0027-\u00279\u0027 represent numbers 0-9. Characters \u0027a\u0027-\u0027z\u0027 represent numbers 10-35. Characters \u0027A\u0027-\u0027Z\u0027 represent numbers 36-61.\u003cbr\u003e\u003cbr\u003e\u003cbr\u003eFor example, if character 7 of element 4 of cost is \u0027B\u0027, the cost of placing a stone into the cell (4,7) is 37.\u003cbr\u003e\u003cbr\u003e\u003cbr\u003eCalculate and return the maximal possible score for the given grid.\u003c/p\u003e\n\u003ch2\u003eInput\u003c/h2\u003e\n\u003cp\u003ethe first line of input contains two integers n,m\u003cbr\u003ethe next n lines give the String[] cost,each line with m characters,the next line came a space,then next n lines give the String [] benefit,each line also with m characters\u003c/p\u003e\n\u003ch2\u003eOutput\u003c/h2\u003e\n\u003cp\u003eoutput only one line indicate the maxima possible score\u003c/p\u003e\n\u003ch2\u003eSample Input\u003c/h2\u003e\n\u003cpre\u003e2 2\n21\n12\n\n21\n12\n\n2 2\nZZ\nZZ\n\n11\n11\n\n3 3\nXXX\nXXX\nXXX\n\naaa\naZa\naaa\n\n2 4\nasam\natik\n\n123A\n45BC\n\n9 8\nIIIIIIII\nIIWWWWII\nIIWIIIII\nIIWIIIII\nIIWWWWII\nIIIIIWII\nIIIIIWII\nIIWWWWII\nIIIIIIII\n\nIIIIIIII\nII0000II\nII0II0II\nII0II0II\nII0000II\nII0II0II\nII0II0II\nII0000II\nIIIIIIII\n\u003c/pre\u003e\n\u003ch2\u003eSample Output\u003c/h2\u003e\n\u003cpre\u003e4\n0\n2\n71\n606\n\u003c/pre\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003ch2\u003eSource\u003c/h2\u003e\n\u003cp\u003eSingle Round Match 558 Round 1 - Division I, Level Three\u003c/p\u003e"}}]}