답안 #42171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42171 2018-02-23T06:00:57 Z nonocut Dango Maker (JOI18_dango_maker) C++14
13 / 100
2 ms 860 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));
		}
		if(t0!=1 && t1!=1) {
			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));
		ans += f(i,1,0,0);
	}
	printf("%d",ans);
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:26: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:27: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 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 2 ms 684 KB Output is correct
4 Correct 2 ms 684 KB Output is correct
5 Correct 2 ms 688 KB Output is correct
6 Correct 2 ms 820 KB Output is correct
7 Correct 2 ms 820 KB Output is correct
8 Correct 1 ms 820 KB Output is correct
9 Correct 2 ms 828 KB Output is correct
10 Correct 2 ms 828 KB Output is correct
11 Correct 2 ms 828 KB Output is correct
12 Correct 2 ms 828 KB Output is correct
13 Correct 2 ms 828 KB Output is correct
14 Correct 2 ms 828 KB Output is correct
15 Correct 2 ms 828 KB Output is correct
16 Correct 1 ms 828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 2 ms 684 KB Output is correct
4 Correct 2 ms 684 KB Output is correct
5 Correct 2 ms 688 KB Output is correct
6 Correct 2 ms 820 KB Output is correct
7 Correct 2 ms 820 KB Output is correct
8 Correct 1 ms 820 KB Output is correct
9 Correct 2 ms 828 KB Output is correct
10 Correct 2 ms 828 KB Output is correct
11 Correct 2 ms 828 KB Output is correct
12 Correct 2 ms 828 KB Output is correct
13 Correct 2 ms 828 KB Output is correct
14 Correct 2 ms 828 KB Output is correct
15 Correct 2 ms 828 KB Output is correct
16 Correct 1 ms 828 KB Output is correct
17 Correct 2 ms 828 KB Output is correct
18 Correct 1 ms 828 KB Output is correct
19 Correct 2 ms 828 KB Output is correct
20 Correct 2 ms 828 KB Output is correct
21 Correct 2 ms 828 KB Output is correct
22 Incorrect 2 ms 860 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 2 ms 684 KB Output is correct
4 Correct 2 ms 684 KB Output is correct
5 Correct 2 ms 688 KB Output is correct
6 Correct 2 ms 820 KB Output is correct
7 Correct 2 ms 820 KB Output is correct
8 Correct 1 ms 820 KB Output is correct
9 Correct 2 ms 828 KB Output is correct
10 Correct 2 ms 828 KB Output is correct
11 Correct 2 ms 828 KB Output is correct
12 Correct 2 ms 828 KB Output is correct
13 Correct 2 ms 828 KB Output is correct
14 Correct 2 ms 828 KB Output is correct
15 Correct 2 ms 828 KB Output is correct
16 Correct 1 ms 828 KB Output is correct
17 Correct 2 ms 828 KB Output is correct
18 Correct 1 ms 828 KB Output is correct
19 Correct 2 ms 828 KB Output is correct
20 Correct 2 ms 828 KB Output is correct
21 Correct 2 ms 828 KB Output is correct
22 Incorrect 2 ms 860 KB Output isn't correct
23 Halted 0 ms 0 KB -