Submission #85605

# Submission time Handle Problem Language Result Execution time Memory
85605 2018-11-21T05:14:35 Z mirbek01 Dango Maker (JOI18_dango_maker) C++17
100 / 100
852 ms 142716 KB
# include <bits/stdc++.h>

using namespace std;

const int N = 3e3 + 2;

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

int main(){
      scanf("%d %d", &n, &m);

      for(int i = 1; i <= n; i ++){
            scanf("\n");
            for(int j = 1; j <= m; j ++)
                  scanf("%c", &c[i][j]);
      }

      for(int i = 1; i <= n; i ++){
            for(int j = 1; j <= m; j ++){
                  if(c[i][j] == 'G'){
                        if(c[i - 1][j] == 'R' && c[i + 1][j] == 'W')
                              fl[1][i][j] = 1;
                        if(c[i][j - 1] == 'R' && c[i][j + 1] == 'W')
                              fl[2][i][j] = 1;
                  }
            }
      }

      for(int d = 2; d <= n + m; d ++){
            int last = 0;
            memset(dp, 0, sizeof(dp));
            for(int i = 1; i <= n; i ++){
                  int j = d - i;
                  if(1 > j || j > m) continue;
                  dp[0][i] = max(dp[0][i - 1], max(dp[1][i - 1], dp[2][i - 1]));
                  if(fl[1][i][j])
                        dp[1][i] = max(dp[0][i - 1], dp[1][i - 1]) + 1;
                  if(fl[2][i][j])
                        dp[2][i] = max(dp[0][i - 1], dp[2][i - 1]) + 1;
                  last = i;
            }
            ans += max(dp[0][last], max(dp[1][last], dp[2][last]));
      }

      cout << ans << endl;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:11:12: 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:14:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("\n");
             ~~~~~^~~~~~
dango_maker.cpp:16:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                   scanf("%c", &c[i][j]);
                   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 424 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 3 ms 476 KB Output is correct
7 Correct 2 ms 476 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 624 KB Output is correct
10 Correct 2 ms 700 KB Output is correct
11 Correct 2 ms 700 KB Output is correct
12 Correct 2 ms 700 KB Output is correct
13 Correct 3 ms 700 KB Output is correct
14 Correct 2 ms 700 KB Output is correct
15 Correct 2 ms 700 KB Output is correct
16 Correct 2 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 424 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 3 ms 476 KB Output is correct
7 Correct 2 ms 476 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 624 KB Output is correct
10 Correct 2 ms 700 KB Output is correct
11 Correct 2 ms 700 KB Output is correct
12 Correct 2 ms 700 KB Output is correct
13 Correct 3 ms 700 KB Output is correct
14 Correct 2 ms 700 KB Output is correct
15 Correct 2 ms 700 KB Output is correct
16 Correct 2 ms 700 KB Output is correct
17 Correct 2 ms 700 KB Output is correct
18 Correct 3 ms 700 KB Output is correct
19 Correct 2 ms 756 KB Output is correct
20 Correct 2 ms 764 KB Output is correct
21 Correct 2 ms 768 KB Output is correct
22 Correct 2 ms 772 KB Output is correct
23 Correct 2 ms 776 KB Output is correct
24 Correct 2 ms 776 KB Output is correct
25 Correct 2 ms 776 KB Output is correct
26 Correct 2 ms 776 KB Output is correct
27 Correct 2 ms 852 KB Output is correct
28 Correct 2 ms 856 KB Output is correct
29 Correct 2 ms 876 KB Output is correct
30 Correct 2 ms 876 KB Output is correct
31 Correct 2 ms 876 KB Output is correct
32 Correct 2 ms 876 KB Output is correct
33 Correct 2 ms 892 KB Output is correct
34 Correct 2 ms 896 KB Output is correct
35 Correct 2 ms 1024 KB Output is correct
36 Correct 2 ms 1024 KB Output is correct
37 Correct 2 ms 1024 KB Output is correct
38 Correct 3 ms 1024 KB Output is correct
39 Correct 2 ms 1024 KB Output is correct
40 Correct 2 ms 1024 KB Output is correct
41 Correct 2 ms 1024 KB Output is correct
42 Correct 2 ms 1024 KB Output is correct
43 Correct 2 ms 1028 KB Output is correct
44 Correct 2 ms 1028 KB Output is correct
45 Correct 2 ms 1032 KB Output is correct
46 Correct 2 ms 1036 KB Output is correct
47 Correct 2 ms 1040 KB Output is correct
48 Correct 2 ms 1044 KB Output is correct
49 Correct 2 ms 1048 KB Output is correct
50 Correct 2 ms 1052 KB Output is correct
51 Correct 2 ms 1056 KB Output is correct
52 Correct 2 ms 1060 KB Output is correct
53 Correct 2 ms 1064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 424 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 3 ms 476 KB Output is correct
7 Correct 2 ms 476 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 624 KB Output is correct
10 Correct 2 ms 700 KB Output is correct
11 Correct 2 ms 700 KB Output is correct
12 Correct 2 ms 700 KB Output is correct
13 Correct 3 ms 700 KB Output is correct
14 Correct 2 ms 700 KB Output is correct
15 Correct 2 ms 700 KB Output is correct
16 Correct 2 ms 700 KB Output is correct
17 Correct 2 ms 700 KB Output is correct
18 Correct 3 ms 700 KB Output is correct
19 Correct 2 ms 756 KB Output is correct
20 Correct 2 ms 764 KB Output is correct
21 Correct 2 ms 768 KB Output is correct
22 Correct 2 ms 772 KB Output is correct
23 Correct 2 ms 776 KB Output is correct
24 Correct 2 ms 776 KB Output is correct
25 Correct 2 ms 776 KB Output is correct
26 Correct 2 ms 776 KB Output is correct
27 Correct 2 ms 852 KB Output is correct
28 Correct 2 ms 856 KB Output is correct
29 Correct 2 ms 876 KB Output is correct
30 Correct 2 ms 876 KB Output is correct
31 Correct 2 ms 876 KB Output is correct
32 Correct 2 ms 876 KB Output is correct
33 Correct 2 ms 892 KB Output is correct
34 Correct 2 ms 896 KB Output is correct
35 Correct 2 ms 1024 KB Output is correct
36 Correct 2 ms 1024 KB Output is correct
37 Correct 2 ms 1024 KB Output is correct
38 Correct 3 ms 1024 KB Output is correct
39 Correct 2 ms 1024 KB Output is correct
40 Correct 2 ms 1024 KB Output is correct
41 Correct 2 ms 1024 KB Output is correct
42 Correct 2 ms 1024 KB Output is correct
43 Correct 2 ms 1028 KB Output is correct
44 Correct 2 ms 1028 KB Output is correct
45 Correct 2 ms 1032 KB Output is correct
46 Correct 2 ms 1036 KB Output is correct
47 Correct 2 ms 1040 KB Output is correct
48 Correct 2 ms 1044 KB Output is correct
49 Correct 2 ms 1048 KB Output is correct
50 Correct 2 ms 1052 KB Output is correct
51 Correct 2 ms 1056 KB Output is correct
52 Correct 2 ms 1060 KB Output is correct
53 Correct 2 ms 1064 KB Output is correct
54 Correct 9 ms 1064 KB Output is correct
55 Correct 30 ms 10352 KB Output is correct
56 Correct 10 ms 10352 KB Output is correct
57 Correct 26 ms 16860 KB Output is correct
58 Correct 86 ms 20464 KB Output is correct
59 Correct 745 ms 90164 KB Output is correct
60 Correct 852 ms 98964 KB Output is correct
61 Correct 790 ms 107840 KB Output is correct
62 Correct 10 ms 107840 KB Output is correct
63 Correct 831 ms 116372 KB Output is correct
64 Correct 703 ms 125152 KB Output is correct
65 Correct 761 ms 133964 KB Output is correct
66 Correct 777 ms 142716 KB Output is correct
67 Correct 621 ms 142716 KB Output is correct
68 Correct 644 ms 142716 KB Output is correct
69 Correct 652 ms 142716 KB Output is correct
70 Correct 79 ms 142716 KB Output is correct
71 Correct 81 ms 142716 KB Output is correct
72 Correct 80 ms 142716 KB Output is correct
73 Correct 79 ms 142716 KB Output is correct
74 Correct 78 ms 142716 KB Output is correct
75 Correct 81 ms 142716 KB Output is correct
76 Correct 80 ms 142716 KB Output is correct
77 Correct 75 ms 142716 KB Output is correct
78 Correct 86 ms 142716 KB Output is correct
79 Correct 88 ms 142716 KB Output is correct
80 Correct 76 ms 142716 KB Output is correct
81 Correct 76 ms 142716 KB Output is correct
82 Correct 99 ms 142716 KB Output is correct
83 Correct 74 ms 142716 KB Output is correct
84 Correct 77 ms 142716 KB Output is correct
85 Correct 73 ms 142716 KB Output is correct
86 Correct 76 ms 142716 KB Output is correct
87 Correct 74 ms 142716 KB Output is correct
88 Correct 80 ms 142716 KB Output is correct
89 Correct 113 ms 142716 KB Output is correct
90 Correct 79 ms 142716 KB Output is correct