728x90
반응형
SMALL
뇌 빼고 모든 케이스를 전부 검사해서 풀었습니다...
전 왜 이럴까요...
chatGPT 최고... 모든 모양의 경우의 수의 모양을 만든 다음;; try, except로 인덱스 넘어가는 부분을 넘기고 최고합을 출력하라고...
진짜 천재인듯... 다음에는 그렇게 풀어보겠슴다..
N,M = map(int, input().split())
list_1 =[]
for i in range(N):
tmp_list = list(map(int,input().split()))
list_1.append(tmp_list)
list_2 = list(map(list, zip(*list_1))) #가로, 세로 전환
t1 = []
for j in range(1,len(list_1)): #정사각형
for j2 in range(1,len(list_1[j])):
t1.append(list_1[j][j2]+list_1[j][j2-1]+list_1[j-1][j2]+list_1[j-1][j2-1])
for j in range(len(list_1)): #일자막대
for j2 in range(3,len(list_1[j])):
t1.append(list_1[j][j2-3]+list_1[j][j2-2]+list_1[j][j2-1]+list_1[j][j2])
for j in range(len(list_2)): #일자막대2
for j2 in range(3,len(list_2[j])):
t1.append(list_2[j][j2-3]+list_2[j][j2-2]+list_2[j][j2-1]+list_2[j][j2])
for j in range(2,len(list_1)): #ㄱ 막대1
for j2 in range(1,len(list_1[j])):
t1.append(list_1[j-2][j2-1]+list_1[j-1][j2-1]+list_1[j][j2-1]+list_1[j][j2])
for j in range(2,len(list_1)): #ㄱ 막대2
for j2 in range(1,len(list_1[j])):
t1.append(list_1[j-2][j2]+list_1[j-1][j2]+list_1[j][j2]+list_1[j][j2-1])
for j in range(2,len(list_1)): #ㄱ 막대2-1
for j2 in range(1,len(list_1[j])):
t1.append(list_1[j-2][j2-1]+list_1[j-2][j2]+list_1[j-1][j2]+list_1[j][j2])
for j in range(2,len(list_1)): #ㄱ 막대2-2
for j2 in range(1,len(list_1[j])):
t1.append(list_1[j-2][j2-1]+list_1[j-1][j2-1]+list_1[j][j2-1]+list_1[j-2][j2])
for j in range(1,len(list_1)): #ㄱ 막대3
for j2 in range(2,len(list_1[j])):
t1.append(list_1[j-1][j2-2]+list_1[j][j2-2]+list_1[j-1][j2-1]+list_1[j-1][j2])
for j in range(1,len(list_1)): #ㄱ 막대4
for j2 in range(2,len(list_1[j])):
t1.append(list_1[j][j2-2]+list_1[j][j2-1]+list_1[j][j2]+list_1[j-1][j2])
for j in range(1,len(list_1)): #ㄱ 막대4-1
for j2 in range(2,len(list_1[j])):
t1.append(list_1[j-1][j2-2]+list_1[j][j2-2]+list_1[j][j2-1]+list_1[j][j2])
for j in range(1,len(list_1)): #ㄱ 막대4-1
for j2 in range(2,len(list_1[j])):
t1.append(list_1[j-1][j2-2]+list_1[j-1][j2-1]+list_1[j-1][j2]+list_1[j][j2])
for j in range(2,len(list_1)): #벌레모양 막대1
for j2 in range(1,len(list_1[j])):
t1.append(list_1[j-2][j2-1]+list_1[j-1][j2-1]+list_1[j-1][j2]+list_1[j][j2])
for j in range(1,len(list_1)): #벌레모양 막대2
for j2 in range(2,len(list_1[j])):
t1.append(list_1[j][j2-2]+list_1[j][j2-1]+list_1[j-1][j2-1]+list_1[j-1][j2])
for j in range(2,len(list_1)): #벌레모양 막대1-1
for j2 in range(1,len(list_1[j])):
t1.append(list_1[j-2][j2]+list_1[j-1][j2-1]+list_1[j-1][j2]+list_1[j][j2-1])
for j in range(1,len(list_1)): #벌레모양 막대2-1
for j2 in range(2,len(list_1[j])):
t1.append(list_1[j-1][j2-2]+list_1[j-1][j2-1]+list_1[j][j2-1]+list_1[j][j2])
for j in range(1,len(list_1)): #ㅗ모양 막대1
for j2 in range(2,len(list_1[j])):
t1.append(list_1[j-1][j2-2]+list_1[j-1][j2-1]+list_1[j-1][j2]+list_1[j][j2-1])
for j in range(1,len(list_1)): #ㅗ모양 막대2
for j2 in range(2,len(list_1[j])):
t1.append(list_1[j][j2-2]+list_1[j][j2-1]+list_1[j][j2]+list_1[j-1][j2-1])
for j in range(2,len(list_1)): #ㅗ모양 막대3
for j2 in range(1,len(list_1[j])):
t1.append(list_1[j-2][j2-1]+list_1[j-1][j2-1]+list_1[j][j2-1]+list_1[j-1][j2])
for j in range(2,len(list_1)): #ㅗ모양 막대4
for j2 in range(1,len(list_1[j])):
t1.append(list_1[j-2][j2]+list_1[j-1][j2]+list_1[j][j2]+list_1[j-1][j2-1])
print(max(t1))
728x90
반응형
LIST
'코테' 카테고리의 다른 글
방화벽 설치하기 (0) | 2023.03.28 |
---|---|
외주 수익 최대화하기 (0) | 2023.03.28 |
바이러스 검사 (0) | 2023.03.28 |
생명과학부 랩 인턴 (0) | 2023.03.28 |
2개의 사탕 (0) | 2023.03.28 |