답안 #42173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42173 2018-02-23T06:04:21 Z nonocut Dango Maker (JOI18_dango_maker) C++14
33 / 100
2000 ms 112468 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 f(int cur, int x, int t0, int t1) {
	if(x==n+1) return 0;
	if(dp[x][t0][t1]==-1) {
		dp[x][t0][t1] = f(cur,x+1,0,t0);
		if(t0!=2 && t1!=2) {
			dp[x][t0][t1] = max(dp[x][t0][t1], a[cur][x].X + f(cur,x+1,1,t0));
		}
		dp[x][t0][t1] = max(dp[x][t0][t1], a[cur][x].Y + f(cur,x+1,2,t0));
	}
	return dp[x][t0][t1];
}
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++) {
		memset(dp,-1,sizeof(dp));
//		printf("i = %d : %d\n",i,f(i,1,0,0));
		ans += f(i,1,0,0);
	}
	printf("%d",ans);
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:24: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:25: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]);
                                                           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 608 KB Output is correct
3 Correct 1 ms 680 KB Output is correct
4 Correct 1 ms 680 KB Output is correct
5 Correct 1 ms 680 KB Output is correct
6 Correct 1 ms 680 KB Output is correct
7 Correct 1 ms 680 KB Output is correct
8 Correct 1 ms 784 KB Output is correct
9 Correct 1 ms 784 KB Output is correct
10 Correct 1 ms 784 KB Output is correct
11 Correct 1 ms 784 KB Output is correct
12 Correct 1 ms 832 KB Output is correct
13 Correct 1 ms 832 KB Output is correct
14 Correct 1 ms 832 KB Output is correct
15 Correct 1 ms 832 KB Output is correct
16 Correct 1 ms 832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 608 KB Output is correct
3 Correct 1 ms 680 KB Output is correct
4 Correct 1 ms 680 KB Output is correct
5 Correct 1 ms 680 KB Output is correct
6 Correct 1 ms 680 KB Output is correct
7 Correct 1 ms 680 KB Output is correct
8 Correct 1 ms 784 KB Output is correct
9 Correct 1 ms 784 KB Output is correct
10 Correct 1 ms 784 KB Output is correct
11 Correct 1 ms 784 KB Output is correct
12 Correct 1 ms 832 KB Output is correct
13 Correct 1 ms 832 KB Output is correct
14 Correct 1 ms 832 KB Output is correct
15 Correct 1 ms 832 KB Output is correct
16 Correct 1 ms 832 KB Output is correct
17 Correct 1 ms 832 KB Output is correct
18 Correct 1 ms 832 KB Output is correct
19 Correct 1 ms 832 KB Output is correct
20 Correct 1 ms 832 KB Output is correct
21 Correct 2 ms 832 KB Output is correct
22 Correct 2 ms 832 KB Output is correct
23 Correct 2 ms 832 KB Output is correct
24 Correct 2 ms 832 KB Output is correct
25 Correct 1 ms 832 KB Output is correct
26 Correct 1 ms 832 KB Output is correct
27 Correct 2 ms 928 KB Output is correct
28 Correct 2 ms 932 KB Output is correct
29 Correct 2 ms 936 KB Output is correct
30 Correct 2 ms 936 KB Output is correct
31 Correct 2 ms 936 KB Output is correct
32 Correct 2 ms 936 KB Output is correct
33 Correct 2 ms 936 KB Output is correct
34 Correct 2 ms 936 KB Output is correct
35 Correct 2 ms 936 KB Output is correct
36 Correct 2 ms 936 KB Output is correct
37 Correct 2 ms 936 KB Output is correct
38 Correct 2 ms 936 KB Output is correct
39 Correct 2 ms 1044 KB Output is correct
40 Correct 2 ms 1044 KB Output is correct
41 Correct 1 ms 1044 KB Output is correct
42 Correct 1 ms 1044 KB Output is correct
43 Correct 2 ms 1044 KB Output is correct
44 Correct 1 ms 1044 KB Output is correct
45 Correct 2 ms 1044 KB Output is correct
46 Correct 2 ms 1044 KB Output is correct
47 Correct 2 ms 1044 KB Output is correct
48 Correct 1 ms 1044 KB Output is correct
49 Correct 2 ms 1044 KB Output is correct
50 Correct 2 ms 1044 KB Output is correct
51 Correct 2 ms 1044 KB Output is correct
52 Correct 2 ms 1044 KB Output is correct
53 Correct 2 ms 1044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 608 KB Output is correct
3 Correct 1 ms 680 KB Output is correct
4 Correct 1 ms 680 KB Output is correct
5 Correct 1 ms 680 KB Output is correct
6 Correct 1 ms 680 KB Output is correct
7 Correct 1 ms 680 KB Output is correct
8 Correct 1 ms 784 KB Output is correct
9 Correct 1 ms 784 KB Output is correct
10 Correct 1 ms 784 KB Output is correct
11 Correct 1 ms 784 KB Output is correct
12 Correct 1 ms 832 KB Output is correct
13 Correct 1 ms 832 KB Output is correct
14 Correct 1 ms 832 KB Output is correct
15 Correct 1 ms 832 KB Output is correct
16 Correct 1 ms 832 KB Output is correct
17 Correct 1 ms 832 KB Output is correct
18 Correct 1 ms 832 KB Output is correct
19 Correct 1 ms 832 KB Output is correct
20 Correct 1 ms 832 KB Output is correct
21 Correct 2 ms 832 KB Output is correct
22 Correct 2 ms 832 KB Output is correct
23 Correct 2 ms 832 KB Output is correct
24 Correct 2 ms 832 KB Output is correct
25 Correct 1 ms 832 KB Output is correct
26 Correct 1 ms 832 KB Output is correct
27 Correct 2 ms 928 KB Output is correct
28 Correct 2 ms 932 KB Output is correct
29 Correct 2 ms 936 KB Output is correct
30 Correct 2 ms 936 KB Output is correct
31 Correct 2 ms 936 KB Output is correct
32 Correct 2 ms 936 KB Output is correct
33 Correct 2 ms 936 KB Output is correct
34 Correct 2 ms 936 KB Output is correct
35 Correct 2 ms 936 KB Output is correct
36 Correct 2 ms 936 KB Output is correct
37 Correct 2 ms 936 KB Output is correct
38 Correct 2 ms 936 KB Output is correct
39 Correct 2 ms 1044 KB Output is correct
40 Correct 2 ms 1044 KB Output is correct
41 Correct 1 ms 1044 KB Output is correct
42 Correct 1 ms 1044 KB Output is correct
43 Correct 2 ms 1044 KB Output is correct
44 Correct 1 ms 1044 KB Output is correct
45 Correct 2 ms 1044 KB Output is correct
46 Correct 2 ms 1044 KB Output is correct
47 Correct 2 ms 1044 KB Output is correct
48 Correct 1 ms 1044 KB Output is correct
49 Correct 2 ms 1044 KB Output is correct
50 Correct 2 ms 1044 KB Output is correct
51 Correct 2 ms 1044 KB Output is correct
52 Correct 2 ms 1044 KB Output is correct
53 Correct 2 ms 1044 KB Output is correct
54 Correct 25 ms 13132 KB Output is correct
55 Correct 1064 ms 22140 KB Output is correct
56 Correct 28 ms 22140 KB Output is correct
57 Correct 487 ms 22140 KB Output is correct
58 Correct 318 ms 22140 KB Output is correct
59 Execution timed out 2045 ms 112468 KB Time limit exceeded
60 Halted 0 ms 0 KB -