백준 1051 숫자 정사각형

김민영·2023년 1월 19일
0

알고리즘

목록 보기
80/125

과정

  • 문제를 잘 읽기
  • 꼭지점에 쓰여있는 수가 가장 큰
  • 정사각형을 찾고
  • 해당 정사각형의 너비 반환하기
N, M = map(int, input().split())
map_lst = [list(map(int, input())) for _ in range(N)]
max = 0

for x1 in range(M-1):
    for y1 in range(N-1):
        for ad in range(1, M-x1):
            if x1 + ad < M and y1 + ad < N:
                if map_lst[y1 + ad][x1 + ad] == map_lst[y1][x1 + ad] == map_lst[y1 + ad][x1] == map_lst[y1][x1] and max < ad:
                    max = ad


print((max+1) ** 2)
  • 문제를 대충 읽어서 고생했다..
profile
노션에 1차 정리합니당 - https://cream-efraasia-f3c.notion.site/4fb02c0dc82e48358e67c61b7ce8ab36?v=

0개의 댓글