Skip to content

Latest commit

 

History

History
26 lines (23 loc) · 511 Bytes

1051.md

File metadata and controls

26 lines (23 loc) · 511 Bytes

1051

Python

N, M = map(int, input().split())
lst = [list(map(int, input())) for _ in range(N)]
answer = 1

grid_size = min(N, M)
for i in range(grid_size-1, 0, -1):
    for y in range(N-i):
        for x in range(M-i):
            ny = y + i
            nx = x + i
            if (lst[y][x] == lst[ny][x] == lst[y][nx] == lst[ny][nx]):
                answer = i+1
                break
        else:
            continue
        break
    else:
        continue
    break
print(answer**2)