답안 #66863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66863 2018-08-12T16:28:27 Z ekrem Dango Maker (JOI18_dango_maker) C++
100 / 100
1759 ms 143860 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 3005
using namespace std;

int n, m, ans, a[N][N], dp[N][N][3];
char c;


//dur = 0 hic koyma
//dur = 1 yatak
//dur = 2 dikey
int f(int i, int j, int dur){
	if(i > n or j > m or i < 1 or j < 1)
		return 0;
	int &r = dp[i][j][dur];
	if(r != -1)
		return r;
	int art = 0;
	if(dur == 1)
		if(a[i][j] == 2 and a[i][j - 1] == 1 and a[i][j + 1] == 3)
			art = 1;
	if(dur == 2)
		if(a[i][j] == 2 and a[i - 1][j] == 1 and a[i + 1][j] == 3)
			art = 1;
	if(dur == 0)
		r = max(f(i - 1, j + 1, 0), max(f(i - 1, j + 1, 1), f(i - 1, j + 1, 2)));
	if(dur == 1)
		r = max(f(i - 1, j + 1, 0), f(i - 1, j + 1, 1)) + art;
	if(dur == 2)
		r = max(f(i - 1, j + 1, 2), f(i - 1, j + 1, 0)) + art;
	return r;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	memset(dp, -1, sizeof dp);
	scanf("%d %d",&n ,&m);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++){
			scanf(" %c",&c);
			if(c == 'R')
				a[i][j] = 1;
			if(c == 'G')
				a[i][j] = 2;
			if(c == 'W')
				a[i][j] = 3;
		}
	for(int i = 1; i <= n; i++)
		ans += max(f(i, 1, 0) , f(i, 1, 2));
	for(int i = 2; i <= m; i++)
		ans += max(f(n, i, 0) , f(n, i, 1));
	printf("%d\n",ans);
	return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:42:7: 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:45:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&c);
    ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 106324 KB Output is correct
2 Correct 89 ms 106536 KB Output is correct
3 Correct 85 ms 106536 KB Output is correct
4 Correct 90 ms 106580 KB Output is correct
5 Correct 86 ms 106632 KB Output is correct
6 Correct 97 ms 106632 KB Output is correct
7 Correct 83 ms 106708 KB Output is correct
8 Correct 93 ms 106708 KB Output is correct
9 Correct 89 ms 106708 KB Output is correct
10 Correct 88 ms 106708 KB Output is correct
11 Correct 89 ms 106708 KB Output is correct
12 Correct 89 ms 106708 KB Output is correct
13 Correct 88 ms 106708 KB Output is correct
14 Correct 82 ms 106708 KB Output is correct
15 Correct 97 ms 106752 KB Output is correct
16 Correct 87 ms 106752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 106324 KB Output is correct
2 Correct 89 ms 106536 KB Output is correct
3 Correct 85 ms 106536 KB Output is correct
4 Correct 90 ms 106580 KB Output is correct
5 Correct 86 ms 106632 KB Output is correct
6 Correct 97 ms 106632 KB Output is correct
7 Correct 83 ms 106708 KB Output is correct
8 Correct 93 ms 106708 KB Output is correct
9 Correct 89 ms 106708 KB Output is correct
10 Correct 88 ms 106708 KB Output is correct
11 Correct 89 ms 106708 KB Output is correct
12 Correct 89 ms 106708 KB Output is correct
13 Correct 88 ms 106708 KB Output is correct
14 Correct 82 ms 106708 KB Output is correct
15 Correct 97 ms 106752 KB Output is correct
16 Correct 87 ms 106752 KB Output is correct
17 Correct 85 ms 106752 KB Output is correct
18 Correct 89 ms 106752 KB Output is correct
19 Correct 87 ms 106752 KB Output is correct
20 Correct 97 ms 106752 KB Output is correct
21 Correct 86 ms 106752 KB Output is correct
22 Correct 82 ms 106752 KB Output is correct
23 Correct 88 ms 106752 KB Output is correct
24 Correct 90 ms 106752 KB Output is correct
25 Correct 88 ms 106752 KB Output is correct
26 Correct 90 ms 106752 KB Output is correct
27 Correct 89 ms 106812 KB Output is correct
28 Correct 86 ms 106812 KB Output is correct
29 Correct 88 ms 106812 KB Output is correct
30 Correct 92 ms 106812 KB Output is correct
31 Correct 93 ms 106812 KB Output is correct
32 Correct 86 ms 106812 KB Output is correct
33 Correct 79 ms 106812 KB Output is correct
34 Correct 83 ms 106812 KB Output is correct
35 Correct 77 ms 106812 KB Output is correct
36 Correct 79 ms 106812 KB Output is correct
37 Correct 80 ms 106812 KB Output is correct
38 Correct 96 ms 106812 KB Output is correct
39 Correct 90 ms 106812 KB Output is correct
40 Correct 84 ms 106812 KB Output is correct
41 Correct 83 ms 106812 KB Output is correct
42 Correct 80 ms 106812 KB Output is correct
43 Correct 89 ms 106812 KB Output is correct
44 Correct 97 ms 106812 KB Output is correct
45 Correct 95 ms 106812 KB Output is correct
46 Correct 86 ms 106812 KB Output is correct
47 Correct 92 ms 106812 KB Output is correct
48 Correct 91 ms 106812 KB Output is correct
49 Correct 86 ms 106812 KB Output is correct
50 Correct 84 ms 106812 KB Output is correct
51 Correct 83 ms 106812 KB Output is correct
52 Correct 82 ms 106812 KB Output is correct
53 Correct 88 ms 106812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 106324 KB Output is correct
2 Correct 89 ms 106536 KB Output is correct
3 Correct 85 ms 106536 KB Output is correct
4 Correct 90 ms 106580 KB Output is correct
5 Correct 86 ms 106632 KB Output is correct
6 Correct 97 ms 106632 KB Output is correct
7 Correct 83 ms 106708 KB Output is correct
8 Correct 93 ms 106708 KB Output is correct
9 Correct 89 ms 106708 KB Output is correct
10 Correct 88 ms 106708 KB Output is correct
11 Correct 89 ms 106708 KB Output is correct
12 Correct 89 ms 106708 KB Output is correct
13 Correct 88 ms 106708 KB Output is correct
14 Correct 82 ms 106708 KB Output is correct
15 Correct 97 ms 106752 KB Output is correct
16 Correct 87 ms 106752 KB Output is correct
17 Correct 85 ms 106752 KB Output is correct
18 Correct 89 ms 106752 KB Output is correct
19 Correct 87 ms 106752 KB Output is correct
20 Correct 97 ms 106752 KB Output is correct
21 Correct 86 ms 106752 KB Output is correct
22 Correct 82 ms 106752 KB Output is correct
23 Correct 88 ms 106752 KB Output is correct
24 Correct 90 ms 106752 KB Output is correct
25 Correct 88 ms 106752 KB Output is correct
26 Correct 90 ms 106752 KB Output is correct
27 Correct 89 ms 106812 KB Output is correct
28 Correct 86 ms 106812 KB Output is correct
29 Correct 88 ms 106812 KB Output is correct
30 Correct 92 ms 106812 KB Output is correct
31 Correct 93 ms 106812 KB Output is correct
32 Correct 86 ms 106812 KB Output is correct
33 Correct 79 ms 106812 KB Output is correct
34 Correct 83 ms 106812 KB Output is correct
35 Correct 77 ms 106812 KB Output is correct
36 Correct 79 ms 106812 KB Output is correct
37 Correct 80 ms 106812 KB Output is correct
38 Correct 96 ms 106812 KB Output is correct
39 Correct 90 ms 106812 KB Output is correct
40 Correct 84 ms 106812 KB Output is correct
41 Correct 83 ms 106812 KB Output is correct
42 Correct 80 ms 106812 KB Output is correct
43 Correct 89 ms 106812 KB Output is correct
44 Correct 97 ms 106812 KB Output is correct
45 Correct 95 ms 106812 KB Output is correct
46 Correct 86 ms 106812 KB Output is correct
47 Correct 92 ms 106812 KB Output is correct
48 Correct 91 ms 106812 KB Output is correct
49 Correct 86 ms 106812 KB Output is correct
50 Correct 84 ms 106812 KB Output is correct
51 Correct 83 ms 106812 KB Output is correct
52 Correct 82 ms 106812 KB Output is correct
53 Correct 88 ms 106812 KB Output is correct
54 Correct 81 ms 106812 KB Output is correct
55 Correct 90 ms 118652 KB Output is correct
56 Correct 89 ms 118652 KB Output is correct
57 Correct 108 ms 118652 KB Output is correct
58 Correct 303 ms 118652 KB Output is correct
59 Correct 1759 ms 142224 KB Output is correct
60 Correct 1740 ms 143684 KB Output is correct
61 Correct 1703 ms 143684 KB Output is correct
62 Correct 81 ms 143684 KB Output is correct
63 Correct 1627 ms 143684 KB Output is correct
64 Correct 1523 ms 143860 KB Output is correct
65 Correct 1657 ms 143860 KB Output is correct
66 Correct 1541 ms 143860 KB Output is correct
67 Correct 1568 ms 143860 KB Output is correct
68 Correct 1579 ms 143860 KB Output is correct
69 Correct 1606 ms 143860 KB Output is correct
70 Correct 235 ms 143860 KB Output is correct
71 Correct 249 ms 143860 KB Output is correct
72 Correct 211 ms 143860 KB Output is correct
73 Correct 214 ms 143860 KB Output is correct
74 Correct 225 ms 143860 KB Output is correct
75 Correct 225 ms 143860 KB Output is correct
76 Correct 254 ms 143860 KB Output is correct
77 Correct 208 ms 143860 KB Output is correct
78 Correct 218 ms 143860 KB Output is correct
79 Correct 212 ms 143860 KB Output is correct
80 Correct 237 ms 143860 KB Output is correct
81 Correct 247 ms 143860 KB Output is correct
82 Correct 241 ms 143860 KB Output is correct
83 Correct 295 ms 143860 KB Output is correct
84 Correct 247 ms 143860 KB Output is correct
85 Correct 240 ms 143860 KB Output is correct
86 Correct 217 ms 143860 KB Output is correct
87 Correct 235 ms 143860 KB Output is correct
88 Correct 236 ms 143860 KB Output is correct
89 Correct 209 ms 143860 KB Output is correct
90 Correct 242 ms 143860 KB Output is correct