Created
March 2, 2020 11:53
-
-
Save inspirit941/0de60cbc2e4d3b5916b67b0d91783162 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
n, m = map(int, sys.stdin.readline().split()) | |
maps = [list(map(int, sys.stdin.readline().split())) for _ in range(n)] | |
answer = 0 | |
def check_shape(maps, shape): | |
global answer | |
y_length = len(maps) - len(shape) | |
x_length = len(maps[0]) - len(shape[0]) | |
for start_y in range(y_length + 1): | |
for start_x in range(x_length + 1): | |
# 좌표 처음부터 순회 | |
value = 0 | |
for y in range(len(shape)): | |
for x in range(len(shape[0])): | |
if shape[y][x] == 1: | |
value += maps[start_y + y][start_x + x] | |
answer = max(answer, value) | |
def rotate(maps): | |
return [list(reversed(i)) for i in list(map(list, zip(*maps)))] | |
line = [[1], | |
[1], | |
[1], | |
[1]] | |
box = [[1,1], | |
[1,1]] | |
shape1 = [ | |
[1,0], | |
[1,0], | |
[1,1], | |
] | |
shape2 = [ | |
[1,0], | |
[1,1], | |
[0,1] | |
] | |
shape3 = [ | |
[1,1,1], | |
[0,1,0] | |
] | |
shape4 = [ | |
[0,1], | |
[0,1], | |
[1,1] | |
] | |
shape5 = [ | |
[0,1], | |
[1,1], | |
[1,0] | |
] | |
shape_list = [line, box, shape1, shape2, shape3, shape4, shape5] | |
for shape in shape_list: | |
if shape == line: | |
for _ in range(2): | |
check_shape(maps, shape) | |
shape = rotate(shape) | |
continue | |
elif shape == box: | |
check_shape(maps, shape) | |
continue | |
else: | |
for _ in range(4): | |
check_shape(maps, shape) | |
shape = rotate(shape) | |
print(answer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment