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 | def check_pal(lst):
global r
if len(lst) <= 1:
r = True
else:
if lst[0] == lst[len(lst)-1]:
check_pal(lst[1:len(lst)-1])
else:
r = False
for _ in range(10):
test_case = int(input())
total = 100
arr = [list(input()) for _ in range(total)]
max_val = 0
for row in arr:
for i in range(total):
for j in range(i,total+1):
r = False
check_pal(row[i:j])
if r == True:
if max_val < len(row[i:j]):
max_val = len(row[i:j])
for col in zip(*arr):
for i in range(total):
for j in range(i,total+1):
r = False
check_pal(col[i:j])
if r == True:
if max_val < len(col[i:j]):
max_val = len(col[i:j])
print("#{} {}".format(test_case, max_val))
|
1216. [S/W 문제해결 기본] 3일차 - 회문2
댓글
댓글 쓰기