Submission #42175

# Submission time Handle Problem Language Result Execution time Memory
42175 2018-02-23T06:09:36 Z nonocut Dango Maker (JOI18_dango_maker) C++14
100 / 100
1126 ms 181076 KB
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define X first
#define Y second
const int maxn = 3005;
int n,m;
char s[maxn][maxn];
int dp[maxn][3][3];
pii a[maxn*2][maxn];
int solve(int cur) {
    int x,t0,t1;
    for(x=n;x>=1;x--) {
        for(t0=0;t0<=2;t0++) {
            for(t1=0;t1<=2;t1++) {
                dp[x][t0][t1] = dp[x+1][0][t0];
                if(t0!=2 && t1!=2) {
                    dp[x][t0][t1] = max(dp[x][t0][t1], a[cur][x].X + dp[x+1][1][t0]);
                }
                dp[x][t0][t1] = max(dp[x][t0][t1], a[cur][x].Y + dp[x+1][2][t0]);
            }
        }
    }
    return dp[1][0][0];
}
int main() {
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf(" %c",&s[i][j]);
	for(i=1;i<=n;i++) {
		for(j=1;j<=m;j++) {
			int t0 = 0, t1 = 0;
			if(s[i][j]=='R' && s[i][j+1]=='G' && s[i][j+2]=='W') {
				t0 = 1;
			}
			if(s[i][j]=='R' && s[i+1][j]=='G' && s[i+2][j]=='W') {
				t1 = 1;
			}
			a[i+j][i] = {t0,t1};
		}
	}
	int ans = 0;
	for(i=2;i<=n+m;i++) {
		ans += solve(i);
	}
	printf("%d",ans);
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:28:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
dango_maker.cpp:29:59: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf(" %c",&s[i][j]);
                                                           ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 476 KB Output is correct
5 Correct 1 ms 476 KB Output is correct
6 Correct 1 ms 476 KB Output is correct
7 Correct 1 ms 532 KB Output is correct
8 Correct 1 ms 548 KB Output is correct
9 Correct 1 ms 548 KB Output is correct
10 Correct 1 ms 548 KB Output is correct
11 Correct 1 ms 548 KB Output is correct
12 Correct 1 ms 548 KB Output is correct
13 Correct 1 ms 548 KB Output is correct
14 Correct 1 ms 676 KB Output is correct
15 Correct 1 ms 676 KB Output is correct
16 Correct 1 ms 676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 476 KB Output is correct
5 Correct 1 ms 476 KB Output is correct
6 Correct 1 ms 476 KB Output is correct
7 Correct 1 ms 532 KB Output is correct
8 Correct 1 ms 548 KB Output is correct
9 Correct 1 ms 548 KB Output is correct
10 Correct 1 ms 548 KB Output is correct
11 Correct 1 ms 548 KB Output is correct
12 Correct 1 ms 548 KB Output is correct
13 Correct 1 ms 548 KB Output is correct
14 Correct 1 ms 676 KB Output is correct
15 Correct 1 ms 676 KB Output is correct
16 Correct 1 ms 676 KB Output is correct
17 Correct 1 ms 676 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 1 ms 676 KB Output is correct
20 Correct 1 ms 676 KB Output is correct
21 Correct 1 ms 676 KB Output is correct
22 Correct 1 ms 676 KB Output is correct
23 Correct 1 ms 676 KB Output is correct
24 Correct 1 ms 676 KB Output is correct
25 Correct 1 ms 676 KB Output is correct
26 Correct 1 ms 676 KB Output is correct
27 Correct 1 ms 676 KB Output is correct
28 Correct 1 ms 676 KB Output is correct
29 Correct 1 ms 676 KB Output is correct
30 Correct 1 ms 676 KB Output is correct
31 Correct 1 ms 676 KB Output is correct
32 Correct 2 ms 676 KB Output is correct
33 Correct 2 ms 676 KB Output is correct
34 Correct 1 ms 676 KB Output is correct
35 Correct 1 ms 676 KB Output is correct
36 Correct 1 ms 676 KB Output is correct
37 Correct 1 ms 676 KB Output is correct
38 Correct 1 ms 676 KB Output is correct
39 Correct 1 ms 676 KB Output is correct
40 Correct 1 ms 676 KB Output is correct
41 Correct 1 ms 676 KB Output is correct
42 Correct 1 ms 676 KB Output is correct
43 Correct 1 ms 676 KB Output is correct
44 Correct 1 ms 676 KB Output is correct
45 Correct 1 ms 676 KB Output is correct
46 Correct 1 ms 676 KB Output is correct
47 Correct 1 ms 676 KB Output is correct
48 Correct 1 ms 676 KB Output is correct
49 Correct 1 ms 676 KB Output is correct
50 Correct 1 ms 676 KB Output is correct
51 Correct 1 ms 676 KB Output is correct
52 Correct 1 ms 676 KB Output is correct
53 Correct 1 ms 676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 476 KB Output is correct
5 Correct 1 ms 476 KB Output is correct
6 Correct 1 ms 476 KB Output is correct
7 Correct 1 ms 532 KB Output is correct
8 Correct 1 ms 548 KB Output is correct
9 Correct 1 ms 548 KB Output is correct
10 Correct 1 ms 548 KB Output is correct
11 Correct 1 ms 548 KB Output is correct
12 Correct 1 ms 548 KB Output is correct
13 Correct 1 ms 548 KB Output is correct
14 Correct 1 ms 676 KB Output is correct
15 Correct 1 ms 676 KB Output is correct
16 Correct 1 ms 676 KB Output is correct
17 Correct 1 ms 676 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 1 ms 676 KB Output is correct
20 Correct 1 ms 676 KB Output is correct
21 Correct 1 ms 676 KB Output is correct
22 Correct 1 ms 676 KB Output is correct
23 Correct 1 ms 676 KB Output is correct
24 Correct 1 ms 676 KB Output is correct
25 Correct 1 ms 676 KB Output is correct
26 Correct 1 ms 676 KB Output is correct
27 Correct 1 ms 676 KB Output is correct
28 Correct 1 ms 676 KB Output is correct
29 Correct 1 ms 676 KB Output is correct
30 Correct 1 ms 676 KB Output is correct
31 Correct 1 ms 676 KB Output is correct
32 Correct 2 ms 676 KB Output is correct
33 Correct 2 ms 676 KB Output is correct
34 Correct 1 ms 676 KB Output is correct
35 Correct 1 ms 676 KB Output is correct
36 Correct 1 ms 676 KB Output is correct
37 Correct 1 ms 676 KB Output is correct
38 Correct 1 ms 676 KB Output is correct
39 Correct 1 ms 676 KB Output is correct
40 Correct 1 ms 676 KB Output is correct
41 Correct 1 ms 676 KB Output is correct
42 Correct 1 ms 676 KB Output is correct
43 Correct 1 ms 676 KB Output is correct
44 Correct 1 ms 676 KB Output is correct
45 Correct 1 ms 676 KB Output is correct
46 Correct 1 ms 676 KB Output is correct
47 Correct 1 ms 676 KB Output is correct
48 Correct 1 ms 676 KB Output is correct
49 Correct 1 ms 676 KB Output is correct
50 Correct 1 ms 676 KB Output is correct
51 Correct 1 ms 676 KB Output is correct
52 Correct 1 ms 676 KB Output is correct
53 Correct 1 ms 676 KB Output is correct
54 Correct 9 ms 12652 KB Output is correct
55 Correct 226 ms 21612 KB Output is correct
56 Correct 13 ms 21612 KB Output is correct
57 Correct 98 ms 21612 KB Output is correct
58 Correct 127 ms 21612 KB Output is correct
59 Correct 1088 ms 102088 KB Output is correct
60 Correct 1126 ms 110928 KB Output is correct
61 Correct 1103 ms 119728 KB Output is correct
62 Correct 9 ms 119728 KB Output is correct
63 Correct 1075 ms 125868 KB Output is correct
64 Correct 1091 ms 137052 KB Output is correct
65 Correct 1096 ms 145888 KB Output is correct
66 Correct 1097 ms 154708 KB Output is correct
67 Correct 1119 ms 163520 KB Output is correct
68 Correct 1099 ms 172256 KB Output is correct
69 Correct 1119 ms 181076 KB Output is correct
70 Correct 124 ms 181076 KB Output is correct
71 Correct 131 ms 181076 KB Output is correct
72 Correct 120 ms 181076 KB Output is correct
73 Correct 127 ms 181076 KB Output is correct
74 Correct 118 ms 181076 KB Output is correct
75 Correct 120 ms 181076 KB Output is correct
76 Correct 120 ms 181076 KB Output is correct
77 Correct 119 ms 181076 KB Output is correct
78 Correct 119 ms 181076 KB Output is correct
79 Correct 119 ms 181076 KB Output is correct
80 Correct 122 ms 181076 KB Output is correct
81 Correct 118 ms 181076 KB Output is correct
82 Correct 119 ms 181076 KB Output is correct
83 Correct 118 ms 181076 KB Output is correct
84 Correct 119 ms 181076 KB Output is correct
85 Correct 119 ms 181076 KB Output is correct
86 Correct 118 ms 181076 KB Output is correct
87 Correct 128 ms 181076 KB Output is correct
88 Correct 118 ms 181076 KB Output is correct
89 Correct 126 ms 181076 KB Output is correct
90 Correct 123 ms 181076 KB Output is correct