White Cloud has a rectangle carpet of nmn*mnm. Grid(i,j)Grid (i,j)Grid(i,j) has a color colorA[i][j]colorA[i][j]colorA[i][j] and a cost costA[i][j]costA[i][j]costA[i][j]. White Rabbit will choose a su
White Cloud has a rectangle carpet of n∗mn*mn∗m. Grid(i,j)Grid (i,j)Grid(i,j) has a color colorA[i][j]colorA[i][j]colorA[i][j] and a cost costA[i][j]costA[i][j]costA[i][j]. White Rabbit will choose a subrectangle BBB of p∗qp*qp∗q from AAA and the color of each grid is colorB[0...p−1][0...q−1]colorB[0...p-1][0...q-1]colorB[0...p−1][0...q−1], the cost of BBB is the (maximum number in the corresponding subrectangle of costA∗(p+1)∗(q+1)costA*(p+1)*(q+1)costA∗(p+1)∗(q+1)). Then colorBcolorBcolorB is continuously translated and copied in an infinite times, that is, expand colorBcolorBcolorB into an infinite new matrix, colorCcolorCcolorC, which satisfies colorC[i][j]=colorB[imodp][jmodq]colorC[i][j]=colorB[i mod p][j mod q]colorC[i][j]=colorB[imodp][jmodq]. White Rabbit must ensure that colorAcolorAcolorA is a subrectangle of colorCcolorCcolorC. You need to find the minimum cost way.
标签: HBC16638carpet题解