n,m=map(int,input().split())
mas=[]
for i in range(n):
mas.append(list(input()))
dic={}
for i in range(n):
for j in range(m):
s1=''
s2=''
for k in range(3):
ik=i+k
jk=j+k
if ik<n:
s1+=mas[ik][j]
if jk<m:
s2+=mas[i][jk]
flag1,flag2=0,0
if s1 in dic:
for k in range(len(dic[s1][1])):
if dic[s1][1][k]==[i,j]:
flag1=1
break
if s2 in dic:
for k in range(len(dic[s2][1])):
if dic[s2][1][k]==[i,j]:
flag2=1
break
if len(s1)==3 and len(s2)==3 and not flag1 and not flag2:
c1=0
c2=0
for l in range(1,3):
s3=''
s4=''
ik=i+k
jk=j+k
for k in range(3):
il=ik+l
jl=jk+l
if il<n:
s3+=mas[il][jk]
if jl<m:
s4+=mas[ik][jl]
if s3==s1:
c1+=1
if s4==s2:
c2+=1
if c1<c2:
if s1 in dic:
dic[s1][1].append([i,j])
dic[s1][1].append([i+1,j])
dic[s1][1].append([i+2,j])
dic[s1][0]+=1
else:
dic[s1]=[1,[[i,j],[i+1,j],[i+2,j]]]
else:
if s2 in dic:
dic[s2][1].append([i,j])
dic[s2][1].append([i,j+1])
dic[s2][1].append([i,j+2])
dic[s2][0]+=1
else:
dic[s2]=[1,[[i,j],[i,j+1],[i,j+2]]]
if len(s2)==3 and not flag2:
if s2 in dic:
dic[s2][1].append([i,j])
dic[s2][1].append([i,j+1])
dic[s2][1].append([i,j+2])
dic[s2][0]+=1
else:
dic[s2]=[1,[[i,j],[i,j+1],[i,j+2]]]
elif len(s1)==3 and not flag1:
if s1 in dic:
dic[s1][1].append([i,j])
dic[s1][1].append([i+1,j])
dic[s1][1].append([i+2,j])
dic[s1][0]+=1
else:
dic[s1]=[1,[[i+1,j],[i,j],[i+2,j]]]
mx=0
for i in dic:
if mx < dic[i][0]:
mx=dic[i][0]
print(mx)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
3164 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
3164 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
3164 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
3164 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |