답안 #635957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
635957 2022-08-27T12:59:45 Z karolb2011 Dango Maker (JOI18_dango_maker) PyPy 3
100 / 100
1165 ms 147128 KB
n,m=list(map(int,input().split()))
s=[]
for i in range(n):
    v=list(input())
    ss=[]
    for p in v:
        if p=="R":
            ss.append(1)
        elif p=="G":
            ss.append(2)
        else:
            ss.append(3)
    s.append(ss)
            
c=0
for i in range(n+m-2):
    j=min(i,m-1)
    k=i-j
    while k<n:
        #print(i,k)
        #print(s)
        if j>=0 and j<m-2 and s[k][j]==1 and s[k][j+1]==2 and s[k][j+2]==3:
            c+=1
            s[k][j]=0
            s[k][j+1]=0
            s[k][j+2]=0
            k+=1
            j-=1
        elif j>=0 and k<n-2 and s[k][j]==1 and s[k+1][j]==2 and s[k+2][j]==3:
            q=k+1
            #print(q,"aaa")
            j-=1
            while j>=0 and j<m-2 and q<n-2 and s[q][j]==1 and s[q+1][j]==2 and s[q+2][j]==3 and s[q][j+1]==2 and s[q][j+2]==3:
                q+=1
                j-=1
            if j>=0 and q<n-2 and s[q][j]==1 and s[q+1][j]==2 and s[q+2][j]==3:
                c+=q-k
                c+=1
                s[q][j]=0
                s[q+1][j]=0
                s[q+2][j]=0
                k=q+1
                j-=1
            elif j>=0 and j<m-2 and s[q][j]==1 and s[q][j+1]==2 and s[q][j+2]==3:
                c+=q-k
                s[q][j]=0
                s[q][j+1]=0
                s[q][j+2]=0
                k=q+1
                j-=1
            else:
                c+=q-k
                s[q+1][j+1]=0
                k=q+1
                j-=1
        else:
            k+=1
            j-=1
    #print(c,"cccc")



print(c)
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 18228 KB Output is correct
2 Correct 33 ms 18224 KB Output is correct
3 Correct 35 ms 18220 KB Output is correct
4 Correct 35 ms 18144 KB Output is correct
5 Correct 35 ms 18220 KB Output is correct
6 Correct 34 ms 18220 KB Output is correct
7 Correct 33 ms 18220 KB Output is correct
8 Correct 37 ms 18228 KB Output is correct
9 Correct 33 ms 18216 KB Output is correct
10 Correct 37 ms 18184 KB Output is correct
11 Correct 34 ms 18132 KB Output is correct
12 Correct 35 ms 18128 KB Output is correct
13 Correct 38 ms 18124 KB Output is correct
14 Correct 36 ms 18128 KB Output is correct
15 Correct 34 ms 18200 KB Output is correct
16 Correct 34 ms 18256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 18228 KB Output is correct
2 Correct 33 ms 18224 KB Output is correct
3 Correct 35 ms 18220 KB Output is correct
4 Correct 35 ms 18144 KB Output is correct
5 Correct 35 ms 18220 KB Output is correct
6 Correct 34 ms 18220 KB Output is correct
7 Correct 33 ms 18220 KB Output is correct
8 Correct 37 ms 18228 KB Output is correct
9 Correct 33 ms 18216 KB Output is correct
10 Correct 37 ms 18184 KB Output is correct
11 Correct 34 ms 18132 KB Output is correct
12 Correct 35 ms 18128 KB Output is correct
13 Correct 38 ms 18124 KB Output is correct
14 Correct 36 ms 18128 KB Output is correct
15 Correct 34 ms 18200 KB Output is correct
16 Correct 34 ms 18256 KB Output is correct
17 Correct 33 ms 18220 KB Output is correct
18 Correct 33 ms 18144 KB Output is correct
19 Correct 33 ms 18228 KB Output is correct
20 Correct 34 ms 18192 KB Output is correct
21 Correct 34 ms 18196 KB Output is correct
22 Correct 41 ms 18220 KB Output is correct
23 Correct 34 ms 18144 KB Output is correct
24 Correct 42 ms 18140 KB Output is correct
25 Correct 35 ms 18192 KB Output is correct
26 Correct 35 ms 18228 KB Output is correct
27 Correct 36 ms 18148 KB Output is correct
28 Correct 38 ms 18200 KB Output is correct
29 Correct 38 ms 18220 KB Output is correct
30 Correct 35 ms 18192 KB Output is correct
31 Correct 36 ms 18220 KB Output is correct
32 Correct 35 ms 18124 KB Output is correct
33 Correct 35 ms 18136 KB Output is correct
34 Correct 33 ms 18228 KB Output is correct
35 Correct 35 ms 18184 KB Output is correct
36 Correct 37 ms 18192 KB Output is correct
37 Correct 36 ms 18192 KB Output is correct
38 Correct 38 ms 18220 KB Output is correct
39 Correct 41 ms 18208 KB Output is correct
40 Correct 34 ms 18128 KB Output is correct
41 Correct 34 ms 18184 KB Output is correct
42 Correct 34 ms 18172 KB Output is correct
43 Correct 35 ms 18212 KB Output is correct
44 Correct 34 ms 18208 KB Output is correct
45 Correct 33 ms 18192 KB Output is correct
46 Correct 35 ms 18228 KB Output is correct
47 Correct 34 ms 18220 KB Output is correct
48 Correct 34 ms 18228 KB Output is correct
49 Correct 42 ms 18116 KB Output is correct
50 Correct 35 ms 18152 KB Output is correct
51 Correct 34 ms 18164 KB Output is correct
52 Correct 34 ms 18112 KB Output is correct
53 Correct 34 ms 18184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 18228 KB Output is correct
2 Correct 33 ms 18224 KB Output is correct
3 Correct 35 ms 18220 KB Output is correct
4 Correct 35 ms 18144 KB Output is correct
5 Correct 35 ms 18220 KB Output is correct
6 Correct 34 ms 18220 KB Output is correct
7 Correct 33 ms 18220 KB Output is correct
8 Correct 37 ms 18228 KB Output is correct
9 Correct 33 ms 18216 KB Output is correct
10 Correct 37 ms 18184 KB Output is correct
11 Correct 34 ms 18132 KB Output is correct
12 Correct 35 ms 18128 KB Output is correct
13 Correct 38 ms 18124 KB Output is correct
14 Correct 36 ms 18128 KB Output is correct
15 Correct 34 ms 18200 KB Output is correct
16 Correct 34 ms 18256 KB Output is correct
17 Correct 33 ms 18220 KB Output is correct
18 Correct 33 ms 18144 KB Output is correct
19 Correct 33 ms 18228 KB Output is correct
20 Correct 34 ms 18192 KB Output is correct
21 Correct 34 ms 18196 KB Output is correct
22 Correct 41 ms 18220 KB Output is correct
23 Correct 34 ms 18144 KB Output is correct
24 Correct 42 ms 18140 KB Output is correct
25 Correct 35 ms 18192 KB Output is correct
26 Correct 35 ms 18228 KB Output is correct
27 Correct 36 ms 18148 KB Output is correct
28 Correct 38 ms 18200 KB Output is correct
29 Correct 38 ms 18220 KB Output is correct
30 Correct 35 ms 18192 KB Output is correct
31 Correct 36 ms 18220 KB Output is correct
32 Correct 35 ms 18124 KB Output is correct
33 Correct 35 ms 18136 KB Output is correct
34 Correct 33 ms 18228 KB Output is correct
35 Correct 35 ms 18184 KB Output is correct
36 Correct 37 ms 18192 KB Output is correct
37 Correct 36 ms 18192 KB Output is correct
38 Correct 38 ms 18220 KB Output is correct
39 Correct 41 ms 18208 KB Output is correct
40 Correct 34 ms 18128 KB Output is correct
41 Correct 34 ms 18184 KB Output is correct
42 Correct 34 ms 18172 KB Output is correct
43 Correct 35 ms 18212 KB Output is correct
44 Correct 34 ms 18208 KB Output is correct
45 Correct 33 ms 18192 KB Output is correct
46 Correct 35 ms 18228 KB Output is correct
47 Correct 34 ms 18220 KB Output is correct
48 Correct 34 ms 18228 KB Output is correct
49 Correct 42 ms 18116 KB Output is correct
50 Correct 35 ms 18152 KB Output is correct
51 Correct 34 ms 18164 KB Output is correct
52 Correct 34 ms 18112 KB Output is correct
53 Correct 34 ms 18184 KB Output is correct
54 Correct 47 ms 19512 KB Output is correct
55 Correct 121 ms 23136 KB Output is correct
56 Correct 87 ms 23156 KB Output is correct
57 Correct 145 ms 24876 KB Output is correct
58 Correct 257 ms 34880 KB Output is correct
59 Correct 1149 ms 145468 KB Output is correct
60 Correct 1127 ms 145560 KB Output is correct
61 Correct 1165 ms 147128 KB Output is correct
62 Correct 60 ms 20156 KB Output is correct
63 Correct 1052 ms 131968 KB Output is correct
64 Correct 937 ms 143272 KB Output is correct
65 Correct 927 ms 142364 KB Output is correct
66 Correct 877 ms 143652 KB Output is correct
67 Correct 838 ms 143596 KB Output is correct
68 Correct 822 ms 141376 KB Output is correct
69 Correct 872 ms 143168 KB Output is correct
70 Correct 180 ms 34224 KB Output is correct
71 Correct 174 ms 33956 KB Output is correct
72 Correct 189 ms 34440 KB Output is correct
73 Correct 182 ms 33908 KB Output is correct
74 Correct 194 ms 33980 KB Output is correct
75 Correct 182 ms 34196 KB Output is correct
76 Correct 180 ms 33916 KB Output is correct
77 Correct 182 ms 34136 KB Output is correct
78 Correct 173 ms 33568 KB Output is correct
79 Correct 181 ms 34060 KB Output is correct
80 Correct 178 ms 33832 KB Output is correct
81 Correct 183 ms 34316 KB Output is correct
82 Correct 185 ms 34300 KB Output is correct
83 Correct 195 ms 34520 KB Output is correct
84 Correct 198 ms 34416 KB Output is correct
85 Correct 180 ms 34044 KB Output is correct
86 Correct 191 ms 34360 KB Output is correct
87 Correct 188 ms 34520 KB Output is correct
88 Correct 216 ms 34396 KB Output is correct
89 Correct 184 ms 34472 KB Output is correct
90 Correct 204 ms 35168 KB Output is correct