-
Notifications
You must be signed in to change notification settings - Fork 0
/
14500.py
65 lines (49 loc) · 2.24 KB
/
14500.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
n, m = map(int, input().split())
array = []
for _ in range(n):
array.append(list(map(int, input().split())))
def tetromino(i, j):
results = []
# 1번 테트로미노
if i + 3 < n:
results.append(array[i][j] + array[i+1][j] + array[i+2][j] + array[i+3][j])
if j + 3 < m:
results.append(array[i][j] + array[i][j+1] + array[i][j+2] + array[i][j+3])
# 2번 테트로미노
if i + 1 < n and j + 1 < m:
results.append(array[i][j] + array[i+1][j] + array[i][j+1] + array[i+1][j+1])
# 3번 테트로미노
if i + 2 < n and j + 1 < m:
tmp = array[i][j] + array[i+1][j] + array[i+2][j]
tmp2 = array[i][j+1] + array[i+1][j+1] + array[i+2][j+1]
results.append(tmp + array[i][j+1])
results.append(tmp + array[i+2][j+1])
results.append(tmp2 + array[i][j])
results.append(tmp2 + array[i+2][j])
if i + 1 < n and j + 2 < m:
tmp = array[i][j] + array[i][j+1] + array[i][j+2]
tmp2 = array[i+1][j] + array[i+1][j+1] + array[i+1][j+2]
results.append(tmp + array[i+1][j])
results.append(tmp + array[i+1][j+2])
results.append(tmp2 + array[i][j])
results.append(tmp2 + array[i][j+2])
# 4번 테트로미노
if i + 2 < n and j + 1 < m:
results.append(array[i][j] + array[i+1][j] + array[i+1][j+1] + array[i+2][j+1])
results.append(array[i][j+1] + array[i+1][j+1] + array[i+1][j] + array[i+2][j])
if i + 1 < n and j + 2 < m:
results.append(array[i][j] + array[i][j+1] + array[i+1][j+1] + array[i+1][j+2])
results.append(array[i+1][j] + array[i+1][j+1] + array[i][j+1] + array[i][j+2])
# 5번 테트로미노
if i + 1 < n and j + 2 < m:
results.append(array[i][j] + array[i][j+1] + array[i][j+2] + array[i+1][j+1])
results.append(array[i][j+1] + array[i+1][j] + array[i+1][j+1] + array[i+1][j+2])
if i + 2 < n and j + 1 < m:
results.append(array[i][j] + array[i+1][j] + array[i+2][j] + array[i+1][j+1])
results.append(array[i+1][j] + array[i][j+1] + array[i+1][j+1] + array[i+2][j+1])
return max(results) if len(results) != 0 else 0
result = 0
for i in range(n):
for j in range(m):
result = max(result, tetromino(i, j))
print(result)