Texture Tile
Time limit2sMemory limit256 MB
Given an N x N image, find the largest square subimage whose top row equals its bottom row and left column equals its right column.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Hash map, Binary search
- Solved
- No attempts yet
Problem
A square raster image is represented by an array of pixels. A texture tile is a square (sub)image whose first row is identical to its last row and whose first column is identical to its last column. This property is useful when covering the surface of a graphics object with repeated copies of a texture, because it lets adjacent copies join together "seamlessly".
Given an image, find the side length of the largest square subimage that is a texture tile.
Input
The first token is the integer . It is followed by integers , the pixel values, given row by row (row first, then row , and so on).
Output
Print a single integer : the side length of the largest texture tile contained in the image. (Since a single pixel is always a texture tile, always holds.)