Submission #670209

# Submission time Handle Problem Language Result Execution time Memory
670209 2022-12-08T09:55:56 Z Quan2003 Dango Maker (JOI18_dango_maker) C++17
100 / 100
783 ms 21000 KB
#include <bits/stdc++.h>
#include <iostream>
#include<queue>
#include<vector>
#include<utility>
using namespace std;
typedef long long ll;
const int sz=2e5+1;
const int sz1=1e3+10;
const int mod = 2111992;
int n,m;
char g[4000][4001];
char d[3][4001];
int dp[3][4001];
int main(){
     cin>>n>>m;
     for(int i = 0; i < n; i++){
         for(int j = 0; j < m; j++){
              cin>>g[i][j];
         }
     }
     int ans = 0;
     for(int i = 1; i < n + m - 2; i++){
       for(int j = 0; j < 3; j++){
                 for(int k = 0; k < 4000; k++) d[j][k] = '?';
          
       }
       for(int j = 0; j < 3; j++){
                for(int k = 0; k < m; k++){
                      int r = i + j - k - 1;
                      int c = k;
                      if(r < 0 or r>=n) continue;
                      d[j][k] = g[r][c];
                }
        }
        for(int j = 0; j < 3; j++){
               for(int k = 0; k < 4000; k++) dp[j][k] = 0;
        }
        for(int j = 0; j < m; j++){
           for(int k = 0; k < 3; k++){
              dp[0][j + 1] = max(dp[0][j + 1], dp[k][j]);
              if(d[1][j] != 'G') continue;
              if(j > 0 and k!= 1 and d[0][j - 1] == 'R' and d[2][j + 1] == 'W'){
                dp[2][j + 1] = max(dp[2][j + 1],dp[k][j] + 1);
              }
              if(k != 2 and d[0][j] == 'R' and d[2][j] == 'W'){
                dp[1][j + 1] = max(dp[1][j + 1],dp[k][j] + 1);
              }
           }
        }
       ans += max(dp[0][m],max(dp[1][m],dp[2][m]));
    }
    cout<<ans<<endl;
}
       
  
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 308 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 308 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 76 ms 340 KB Output is correct
55 Correct 12 ms 11988 KB Output is correct
56 Correct 76 ms 320 KB Output is correct
57 Correct 8 ms 8148 KB Output is correct
58 Correct 76 ms 5232 KB Output is correct
59 Correct 773 ms 20972 KB Output is correct
60 Correct 765 ms 20888 KB Output is correct
61 Correct 783 ms 20928 KB Output is correct
62 Correct 66 ms 340 KB Output is correct
63 Correct 733 ms 20516 KB Output is correct
64 Correct 747 ms 20948 KB Output is correct
65 Correct 730 ms 20884 KB Output is correct
66 Correct 723 ms 21000 KB Output is correct
67 Correct 724 ms 20932 KB Output is correct
68 Correct 660 ms 20840 KB Output is correct
69 Correct 716 ms 20812 KB Output is correct
70 Correct 75 ms 5232 KB Output is correct
71 Correct 74 ms 5204 KB Output is correct
72 Correct 72 ms 5188 KB Output is correct
73 Correct 72 ms 5160 KB Output is correct
74 Correct 73 ms 5196 KB Output is correct
75 Correct 73 ms 5140 KB Output is correct
76 Correct 74 ms 5164 KB Output is correct
77 Correct 76 ms 5224 KB Output is correct
78 Correct 76 ms 5204 KB Output is correct
79 Correct 72 ms 5148 KB Output is correct
80 Correct 73 ms 5232 KB Output is correct
81 Correct 72 ms 5196 KB Output is correct
82 Correct 76 ms 5296 KB Output is correct
83 Correct 72 ms 5228 KB Output is correct
84 Correct 76 ms 5152 KB Output is correct
85 Correct 73 ms 5144 KB Output is correct
86 Correct 73 ms 5240 KB Output is correct
87 Correct 73 ms 5180 KB Output is correct
88 Correct 75 ms 5228 KB Output is correct
89 Correct 73 ms 5184 KB Output is correct
90 Correct 71 ms 5196 KB Output is correct