-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBACKJOON14500.py
More file actions
109 lines (106 loc) · 4.33 KB
/
BACKJOON14500.py
File metadata and controls
109 lines (106 loc) · 4.33 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#테트로미노
n, m = map(int, input().split())
graph = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
numbers = list(map(int, input().split()))
for j in range(m):
graph[i][j] = numbers[j]
max_sum = 0
for i in range(n):
for j in range(m):
#일자 가로
if j + 3 < m:
temp = graph[i][j] + graph[i][j + 1] + graph[i][j + 2] + graph[i][j + 3]
if temp > max_sum:
max_sum = temp
#일자 세로
if i + 3 < n:
temp = graph[i][j] + graph[i + 1][j] + graph[i + 2][j] + graph[i + 3][j]
if temp > max_sum:
max_sum = temp
#정사각형
if i + 1 < n and j + 1 < m:
temp = graph[i][j] + graph[i][j + 1] + graph[i + 1][j] + graph[i + 1][j + 1]
if temp > max_sum:
max_sum = temp
#ㅗ
if i + 1 < n and j - 1 >= 0 and j + 1 < m:
temp = graph[i][j] + graph[i + 1][j - 1] + graph[i + 1][j] + graph[i + 1][j + 1]
if temp > max_sum:
max_sum = temp
#ㅜ
if i - 1 >= 0 and j - 1 >= 0 and j + 1 < m:
temp = graph[i][j] + graph[i - 1][j - 1] + graph[i - 1][j] + graph[i - 1][j + 1]
if temp > max_sum:
max_sum = temp
#ㅓ
if j + 1 < m and i - 1 >= 0 and i + 1 < n:
temp = graph[i][j] + graph[i - 1][j + 1] + graph[i][j + 1] + graph[i + 1][j + 1]
if temp > max_sum:
max_sum = temp
#ㅏ
if j - 1 >= 0 and i - 1 >= 0 and i + 1 < n:
temp = graph[i][j] + graph[i - 1][j - 1] + graph[i][j- 1] + graph[i + 1][j - 1]
if temp > max_sum:
max_sum = temp
#번개 세로 오른쪽
if i + 2 < n and j + 1 < m:
temp = graph[i][j] + graph[i + 1][j] + graph[i + 1][j + 1] + graph[i + 2][j + 1]
if temp > max_sum:
max_sum = temp
#번개 세로 왼쪽
if i + 2 < n and j - 1 >= 0:
temp = graph[i][j] + graph[i + 1][j] + graph[i + 1][j - 1] + graph[i + 2][j - 1]
if temp > max_sum:
max_sum = temp
#번개 가로 오른쪽
if j + 2 < m and i + 1 < n:
temp = graph[i][j] + graph[i][j + 1] + graph[i + 1][j + 1] + graph[i + 1][j + 2]
if temp > max_sum:
max_sum = temp
# 번개 가로 왼쪽
if j - 2 >= 0 and i + 1 < n:
temp = graph[i][j] + graph[i][j - 1] + graph[i + 1][j - 1] + graph[i + 1][j - 2]
if temp > max_sum:
max_sum = temp
#ㄴ 세로 길게
if i - 2 >= 0 and j - 1 >= 0:
temp = graph[i][j] + graph[i][j - 1] + graph[i - 1][j - 1] + graph[i - 2][j - 1]
if temp > max_sum:
max_sum = temp
#ㄴ 가로 길게
if i + 1 < n and j + 2 < m:
temp = graph[i][j] + graph[i + 1][j] + graph[i + 1][j + 1] + graph[i + 1][j + 2]
if temp > max_sum:
max_sum = temp
#ㄱ 세로 길게
if i + 2 < n and j + 1 < m:
temp = graph[i][j] + graph[i][j + 1] + graph[i + 1][j + 1] + graph[i + 2][j + 1]
if temp > max_sum:
max_sum = temp
#ㄱ 가로 길게
if i - 1 >= 0 and j - 2 >= 0:
temp = graph[i][j] + graph[i - 1][j] + graph[i - 1][j - 1] + graph[i - 1][j - 2]
if temp > max_sum:
max_sum = temp
# ㄴ 세로 길게 대칭
if i - 2 >= 0 and j + 1 < m:
temp = graph[i][j] + graph[i][j + 1] + graph[i - 1][j + 1] + graph[i - 2][j + 1]
if temp > max_sum:
max_sum = temp
# ㄴ 가로 길게 대칭
if i + 1 < n and j - 2 >= 0:
temp = graph[i][j] + graph[i + 1][j] + graph[i + 1][j - 1] + graph[i + 1][j - 2]
if temp > max_sum:
max_sum = temp
# ㄱ 세로 길게 대칭
if i + 2 < n and j - 1 >= 0:
temp = graph[i][j] + graph[i][j - 1] + graph[i + 1][j - 1] + graph[i + 2][j - 1]
if temp > max_sum:
max_sum = temp
# ㄱ 가로 길게 대칭
if i - 1 >= 0 and j + 2 < m:
temp = graph[i][j] + graph[i - 1][j] + graph[i - 1][j + 1] + graph[i - 1][j + 2]
if temp > max_sum:
max_sum = temp
print(max_sum)