답안 #66854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66854 2018-08-12T16:07:03 Z yusufake Dango Maker (JOI18_dango_maker) C++
100 / 100
1393 ms 198408 KB
#include<bits/stdc++.h> 
using namespace std; 
 
#define mp make_pair 
#define pb push_back 
#define st first 
#define nd second 
 
typedef long long ll; 
typedef pair < int , int > pp; 
const int mod = 1e9 + 7; 
const int N   = 3e3 + 3; 
 
int M[N][N][2][2],H[N][N],m,n,i,j,ans;
char A[N][N];
 
int f(int x, int y, int a, int b){
    if(A[x][y] != 'G') return 0;
    H[x][y] = 1;
    int &r = M[x][y][a][b];
    if(r != -1) return r;
    if(a && A[x][y-1] == 'R') r = max(r , f(x+1,y-1,A[x+1][y]=='W',0)+1);
    if(b && A[x+1][y] == 'W') r = max(r , f(x+1,y-1,0,A[x][y-1]=='R')+1);
    return r = max(r , f(x+1,y-1,A[x+1][y]=='W',A[x][y-1]=='R'));   
}
 
int main(){
    scanf("%d%d",&m,&n);
    for(i=1;i<=m;i++)
        for(j=1;j<=n;j++)
            scanf(" %c", &A[i][j]);
            
    memset(M , -1 , sizeof M);
    for(i=1;i<=m;i++)
        for(j=n; j ;j--)
            if(A[i][j] == 'G' && !H[i][j])
                ans += f(i,j,A[i][j+1]=='W',A[i-1][j]=='R');

    printf("%d",ans);
    return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&m,&n);
     ~~~~~^~~~~~~~~~~~~~
dango_maker.cpp:31:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c", &A[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 141560 KB Output is correct
2 Correct 105 ms 141560 KB Output is correct
3 Correct 111 ms 141724 KB Output is correct
4 Correct 118 ms 141724 KB Output is correct
5 Correct 109 ms 141856 KB Output is correct
6 Correct 119 ms 141884 KB Output is correct
7 Correct 111 ms 141884 KB Output is correct
8 Correct 105 ms 141884 KB Output is correct
9 Correct 107 ms 141884 KB Output is correct
10 Correct 119 ms 141884 KB Output is correct
11 Correct 109 ms 141884 KB Output is correct
12 Correct 116 ms 141884 KB Output is correct
13 Correct 111 ms 141884 KB Output is correct
14 Correct 116 ms 141884 KB Output is correct
15 Correct 120 ms 141992 KB Output is correct
16 Correct 123 ms 141992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 141560 KB Output is correct
2 Correct 105 ms 141560 KB Output is correct
3 Correct 111 ms 141724 KB Output is correct
4 Correct 118 ms 141724 KB Output is correct
5 Correct 109 ms 141856 KB Output is correct
6 Correct 119 ms 141884 KB Output is correct
7 Correct 111 ms 141884 KB Output is correct
8 Correct 105 ms 141884 KB Output is correct
9 Correct 107 ms 141884 KB Output is correct
10 Correct 119 ms 141884 KB Output is correct
11 Correct 109 ms 141884 KB Output is correct
12 Correct 116 ms 141884 KB Output is correct
13 Correct 111 ms 141884 KB Output is correct
14 Correct 116 ms 141884 KB Output is correct
15 Correct 120 ms 141992 KB Output is correct
16 Correct 123 ms 141992 KB Output is correct
17 Correct 113 ms 141992 KB Output is correct
18 Correct 113 ms 141992 KB Output is correct
19 Correct 115 ms 141992 KB Output is correct
20 Correct 119 ms 142016 KB Output is correct
21 Correct 119 ms 142016 KB Output is correct
22 Correct 116 ms 142016 KB Output is correct
23 Correct 141 ms 142060 KB Output is correct
24 Correct 123 ms 142060 KB Output is correct
25 Correct 115 ms 142060 KB Output is correct
26 Correct 105 ms 142060 KB Output is correct
27 Correct 116 ms 142060 KB Output is correct
28 Correct 113 ms 142060 KB Output is correct
29 Correct 108 ms 142060 KB Output is correct
30 Correct 108 ms 142060 KB Output is correct
31 Correct 110 ms 142060 KB Output is correct
32 Correct 114 ms 142060 KB Output is correct
33 Correct 118 ms 142060 KB Output is correct
34 Correct 109 ms 142060 KB Output is correct
35 Correct 109 ms 142060 KB Output is correct
36 Correct 108 ms 142060 KB Output is correct
37 Correct 118 ms 142060 KB Output is correct
38 Correct 113 ms 142060 KB Output is correct
39 Correct 119 ms 142060 KB Output is correct
40 Correct 119 ms 142060 KB Output is correct
41 Correct 113 ms 142060 KB Output is correct
42 Correct 122 ms 142060 KB Output is correct
43 Correct 107 ms 142060 KB Output is correct
44 Correct 113 ms 142060 KB Output is correct
45 Correct 110 ms 142060 KB Output is correct
46 Correct 115 ms 142060 KB Output is correct
47 Correct 114 ms 142060 KB Output is correct
48 Correct 123 ms 142060 KB Output is correct
49 Correct 117 ms 142060 KB Output is correct
50 Correct 118 ms 142144 KB Output is correct
51 Correct 123 ms 142144 KB Output is correct
52 Correct 120 ms 142144 KB Output is correct
53 Correct 125 ms 142144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 141560 KB Output is correct
2 Correct 105 ms 141560 KB Output is correct
3 Correct 111 ms 141724 KB Output is correct
4 Correct 118 ms 141724 KB Output is correct
5 Correct 109 ms 141856 KB Output is correct
6 Correct 119 ms 141884 KB Output is correct
7 Correct 111 ms 141884 KB Output is correct
8 Correct 105 ms 141884 KB Output is correct
9 Correct 107 ms 141884 KB Output is correct
10 Correct 119 ms 141884 KB Output is correct
11 Correct 109 ms 141884 KB Output is correct
12 Correct 116 ms 141884 KB Output is correct
13 Correct 111 ms 141884 KB Output is correct
14 Correct 116 ms 141884 KB Output is correct
15 Correct 120 ms 141992 KB Output is correct
16 Correct 123 ms 141992 KB Output is correct
17 Correct 113 ms 141992 KB Output is correct
18 Correct 113 ms 141992 KB Output is correct
19 Correct 115 ms 141992 KB Output is correct
20 Correct 119 ms 142016 KB Output is correct
21 Correct 119 ms 142016 KB Output is correct
22 Correct 116 ms 142016 KB Output is correct
23 Correct 141 ms 142060 KB Output is correct
24 Correct 123 ms 142060 KB Output is correct
25 Correct 115 ms 142060 KB Output is correct
26 Correct 105 ms 142060 KB Output is correct
27 Correct 116 ms 142060 KB Output is correct
28 Correct 113 ms 142060 KB Output is correct
29 Correct 108 ms 142060 KB Output is correct
30 Correct 108 ms 142060 KB Output is correct
31 Correct 110 ms 142060 KB Output is correct
32 Correct 114 ms 142060 KB Output is correct
33 Correct 118 ms 142060 KB Output is correct
34 Correct 109 ms 142060 KB Output is correct
35 Correct 109 ms 142060 KB Output is correct
36 Correct 108 ms 142060 KB Output is correct
37 Correct 118 ms 142060 KB Output is correct
38 Correct 113 ms 142060 KB Output is correct
39 Correct 119 ms 142060 KB Output is correct
40 Correct 119 ms 142060 KB Output is correct
41 Correct 113 ms 142060 KB Output is correct
42 Correct 122 ms 142060 KB Output is correct
43 Correct 107 ms 142060 KB Output is correct
44 Correct 113 ms 142060 KB Output is correct
45 Correct 110 ms 142060 KB Output is correct
46 Correct 115 ms 142060 KB Output is correct
47 Correct 114 ms 142060 KB Output is correct
48 Correct 123 ms 142060 KB Output is correct
49 Correct 117 ms 142060 KB Output is correct
50 Correct 118 ms 142144 KB Output is correct
51 Correct 123 ms 142144 KB Output is correct
52 Correct 120 ms 142144 KB Output is correct
53 Correct 125 ms 142144 KB Output is correct
54 Correct 115 ms 142144 KB Output is correct
55 Correct 123 ms 154788 KB Output is correct
56 Correct 109 ms 154788 KB Output is correct
57 Correct 126 ms 155840 KB Output is correct
58 Correct 218 ms 155840 KB Output is correct
59 Correct 932 ms 196140 KB Output is correct
60 Correct 963 ms 198100 KB Output is correct
61 Correct 893 ms 198100 KB Output is correct
62 Correct 113 ms 198100 KB Output is correct
63 Correct 826 ms 198100 KB Output is correct
64 Correct 1348 ms 198344 KB Output is correct
65 Correct 1259 ms 198344 KB Output is correct
66 Correct 1393 ms 198408 KB Output is correct
67 Correct 715 ms 198408 KB Output is correct
68 Correct 823 ms 198408 KB Output is correct
69 Correct 768 ms 198408 KB Output is correct
70 Correct 244 ms 198408 KB Output is correct
71 Correct 231 ms 198408 KB Output is correct
72 Correct 275 ms 198408 KB Output is correct
73 Correct 225 ms 198408 KB Output is correct
74 Correct 249 ms 198408 KB Output is correct
75 Correct 236 ms 198408 KB Output is correct
76 Correct 231 ms 198408 KB Output is correct
77 Correct 260 ms 198408 KB Output is correct
78 Correct 237 ms 198408 KB Output is correct
79 Correct 225 ms 198408 KB Output is correct
80 Correct 267 ms 198408 KB Output is correct
81 Correct 253 ms 198408 KB Output is correct
82 Correct 236 ms 198408 KB Output is correct
83 Correct 229 ms 198408 KB Output is correct
84 Correct 243 ms 198408 KB Output is correct
85 Correct 239 ms 198408 KB Output is correct
86 Correct 231 ms 198408 KB Output is correct
87 Correct 232 ms 198408 KB Output is correct
88 Correct 229 ms 198408 KB Output is correct
89 Correct 254 ms 198408 KB Output is correct
90 Correct 231 ms 198408 KB Output is correct