답안 #1049849

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1049849 2024-08-09T05:46:06 Z vjudge1 Dango Maker (JOI18_dango_maker) Python 3
0 / 100
11 ms 3284 KB
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=''
                for k in range(3):
                    ik=i+k+l
                    jk=j+k+l
                    if ik<n:
                        s3+=mas[ik][j]
                    if jk<m:
                        s4+=mas[i][jk]
                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 Correct 11 ms 3164 KB Output is correct
2 Correct 9 ms 3164 KB Output is correct
3 Correct 11 ms 3284 KB Output is correct
4 Incorrect 9 ms 3164 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 3164 KB Output is correct
2 Correct 9 ms 3164 KB Output is correct
3 Correct 11 ms 3284 KB Output is correct
4 Incorrect 9 ms 3164 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 3164 KB Output is correct
2 Correct 9 ms 3164 KB Output is correct
3 Correct 11 ms 3284 KB Output is correct
4 Incorrect 9 ms 3164 KB Output isn't correct
5 Halted 0 ms 0 KB -