Submission #79962

# Submission time Handle Problem Language Result Execution time Memory
79962 2018-10-17T16:33:20 Z Just_Solve_The_Problem Dango Maker (JOI18_dango_maker) C++11
100 / 100
304 ms 47828 KB
#include <bits/stdc++.h>

using namespace std;

const int N = (int)3e3 + 7;

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

main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    getchar();
    for (int j = 1; j <= m; j++) {
      C[i][j] = getchar();
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (C[i][j] == 'G') {
	if (C[i][j - 1] == 'R' && C[i][j + 1] == 'W')
	  c[i][j] |= 1;
        if (C[i - 1][j] == 'R' && C[i + 1][j] == 'W')
	  c[i][j] |= 2;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = i;
    int y = 1;
    memset(dp, 0, sizeof dp);
    while (x >= 1 && y <= m) {
      dp[0][y] = dp[0][y - 1];
      dp[1][y] = dp[1][y - 1];
      dp[2][y] = dp[2][y - 1];
      dp[0][y] = max(dp[1][y - 1], dp[2][y - 1]);
      if (c[x][y] & 1) {
	dp[1][y] = max(dp[1][y - 1], dp[0][y - 1]) + 1;
      }
      if (c[x][y] & 2) {
	dp[2][y] = max(dp[2][y - 1], dp[0][y - 1]) + 1;
      }
      x--;
      y++;
    }
    ans += max(dp[0][y - 1], max(dp[1][y - 1], dp[2][y - 1]));
    //cout << i << ' ' << ans << endl;
  }
  
  for (int i = 2; i <= m; i++) {
    int x = n;
    int y = i;
    memset(dp, 0, sizeof dp);
    while (x >= 1 && y <= m) {
      dp[0][y] = dp[0][y - 1];
      dp[1][y] = dp[1][y - 1];
      dp[2][y] = dp[2][y - 1];
      dp[0][y] = max(dp[1][y - 1], dp[2][y - 1]);
      if (c[x][y] & 1) {
	dp[1][y] = max(dp[1][y - 1], dp[0][y - 1]) + 1;
      }
      if (c[x][y] & 2) {
	dp[2][y] = max(dp[2][y - 1], dp[0][y - 1]) + 1;
      }
      x--;
      y++;
    }
    ans += max(dp[0][y - 1], max(dp[1][y - 1], dp[2][y - 1]));
    //cout << i << ' ' << ans << endl;
  }
  cout << ans;
}

Compilation message

dango_maker.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 3 ms 612 KB Output is correct
5 Correct 2 ms 612 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 3 ms 656 KB Output is correct
8 Correct 2 ms 656 KB Output is correct
9 Correct 2 ms 656 KB Output is correct
10 Correct 2 ms 656 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 3 ms 656 KB Output is correct
13 Correct 3 ms 664 KB Output is correct
14 Correct 2 ms 668 KB Output is correct
15 Correct 2 ms 672 KB Output is correct
16 Correct 2 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 3 ms 612 KB Output is correct
5 Correct 2 ms 612 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 3 ms 656 KB Output is correct
8 Correct 2 ms 656 KB Output is correct
9 Correct 2 ms 656 KB Output is correct
10 Correct 2 ms 656 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 3 ms 656 KB Output is correct
13 Correct 3 ms 664 KB Output is correct
14 Correct 2 ms 668 KB Output is correct
15 Correct 2 ms 672 KB Output is correct
16 Correct 2 ms 672 KB Output is correct
17 Correct 2 ms 672 KB Output is correct
18 Correct 2 ms 800 KB Output is correct
19 Correct 2 ms 800 KB Output is correct
20 Correct 3 ms 800 KB Output is correct
21 Correct 3 ms 800 KB Output is correct
22 Correct 3 ms 800 KB Output is correct
23 Correct 2 ms 800 KB Output is correct
24 Correct 3 ms 800 KB Output is correct
25 Correct 3 ms 800 KB Output is correct
26 Correct 2 ms 800 KB Output is correct
27 Correct 3 ms 804 KB Output is correct
28 Correct 3 ms 804 KB Output is correct
29 Correct 3 ms 804 KB Output is correct
30 Correct 2 ms 804 KB Output is correct
31 Correct 2 ms 804 KB Output is correct
32 Correct 2 ms 804 KB Output is correct
33 Correct 2 ms 804 KB Output is correct
34 Correct 2 ms 804 KB Output is correct
35 Correct 2 ms 804 KB Output is correct
36 Correct 2 ms 804 KB Output is correct
37 Correct 2 ms 804 KB Output is correct
38 Correct 2 ms 804 KB Output is correct
39 Correct 2 ms 804 KB Output is correct
40 Correct 3 ms 804 KB Output is correct
41 Correct 3 ms 804 KB Output is correct
42 Correct 2 ms 804 KB Output is correct
43 Correct 2 ms 804 KB Output is correct
44 Correct 2 ms 804 KB Output is correct
45 Correct 3 ms 804 KB Output is correct
46 Correct 2 ms 804 KB Output is correct
47 Correct 2 ms 804 KB Output is correct
48 Correct 2 ms 804 KB Output is correct
49 Correct 2 ms 820 KB Output is correct
50 Correct 2 ms 820 KB Output is correct
51 Correct 2 ms 820 KB Output is correct
52 Correct 3 ms 820 KB Output is correct
53 Correct 2 ms 820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 3 ms 612 KB Output is correct
5 Correct 2 ms 612 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 3 ms 656 KB Output is correct
8 Correct 2 ms 656 KB Output is correct
9 Correct 2 ms 656 KB Output is correct
10 Correct 2 ms 656 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 3 ms 656 KB Output is correct
13 Correct 3 ms 664 KB Output is correct
14 Correct 2 ms 668 KB Output is correct
15 Correct 2 ms 672 KB Output is correct
16 Correct 2 ms 672 KB Output is correct
17 Correct 2 ms 672 KB Output is correct
18 Correct 2 ms 800 KB Output is correct
19 Correct 2 ms 800 KB Output is correct
20 Correct 3 ms 800 KB Output is correct
21 Correct 3 ms 800 KB Output is correct
22 Correct 3 ms 800 KB Output is correct
23 Correct 2 ms 800 KB Output is correct
24 Correct 3 ms 800 KB Output is correct
25 Correct 3 ms 800 KB Output is correct
26 Correct 2 ms 800 KB Output is correct
27 Correct 3 ms 804 KB Output is correct
28 Correct 3 ms 804 KB Output is correct
29 Correct 3 ms 804 KB Output is correct
30 Correct 2 ms 804 KB Output is correct
31 Correct 2 ms 804 KB Output is correct
32 Correct 2 ms 804 KB Output is correct
33 Correct 2 ms 804 KB Output is correct
34 Correct 2 ms 804 KB Output is correct
35 Correct 2 ms 804 KB Output is correct
36 Correct 2 ms 804 KB Output is correct
37 Correct 2 ms 804 KB Output is correct
38 Correct 2 ms 804 KB Output is correct
39 Correct 2 ms 804 KB Output is correct
40 Correct 3 ms 804 KB Output is correct
41 Correct 3 ms 804 KB Output is correct
42 Correct 2 ms 804 KB Output is correct
43 Correct 2 ms 804 KB Output is correct
44 Correct 2 ms 804 KB Output is correct
45 Correct 3 ms 804 KB Output is correct
46 Correct 2 ms 804 KB Output is correct
47 Correct 2 ms 804 KB Output is correct
48 Correct 2 ms 804 KB Output is correct
49 Correct 2 ms 820 KB Output is correct
50 Correct 2 ms 820 KB Output is correct
51 Correct 2 ms 820 KB Output is correct
52 Correct 3 ms 820 KB Output is correct
53 Correct 2 ms 820 KB Output is correct
54 Correct 6 ms 820 KB Output is correct
55 Correct 21 ms 10160 KB Output is correct
56 Correct 7 ms 10160 KB Output is correct
57 Correct 16 ms 13760 KB Output is correct
58 Correct 39 ms 13760 KB Output is correct
59 Correct 300 ms 46828 KB Output is correct
60 Correct 304 ms 46836 KB Output is correct
61 Correct 304 ms 46836 KB Output is correct
62 Correct 7 ms 46836 KB Output is correct
63 Correct 286 ms 46836 KB Output is correct
64 Correct 230 ms 46836 KB Output is correct
65 Correct 231 ms 46836 KB Output is correct
66 Correct 243 ms 47828 KB Output is correct
67 Correct 193 ms 47828 KB Output is correct
68 Correct 197 ms 47828 KB Output is correct
69 Correct 234 ms 47828 KB Output is correct
70 Correct 30 ms 47828 KB Output is correct
71 Correct 31 ms 47828 KB Output is correct
72 Correct 30 ms 47828 KB Output is correct
73 Correct 32 ms 47828 KB Output is correct
74 Correct 35 ms 47828 KB Output is correct
75 Correct 34 ms 47828 KB Output is correct
76 Correct 32 ms 47828 KB Output is correct
77 Correct 31 ms 47828 KB Output is correct
78 Correct 29 ms 47828 KB Output is correct
79 Correct 29 ms 47828 KB Output is correct
80 Correct 29 ms 47828 KB Output is correct
81 Correct 29 ms 47828 KB Output is correct
82 Correct 30 ms 47828 KB Output is correct
83 Correct 29 ms 47828 KB Output is correct
84 Correct 32 ms 47828 KB Output is correct
85 Correct 30 ms 47828 KB Output is correct
86 Correct 38 ms 47828 KB Output is correct
87 Correct 30 ms 47828 KB Output is correct
88 Correct 45 ms 47828 KB Output is correct
89 Correct 30 ms 47828 KB Output is correct
90 Correct 45 ms 47828 KB Output is correct