답안 #1068911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1068911 2024-08-21T13:07:25 Z epicci23 Dango Maker (JOI18_dango_maker) C++17
100 / 100
134 ms 124244 KB
#include "bits/stdc++.h"
#define all(v) v.begin() , v.end()
using namespace std;

const int INF = 1e9;
const int N = 3005;
int dp[N][N][2],ans[N][N];
void _(){
  int n,m,res=0;
  cin >> n >> m;
  vector<string> v;
  v.push_back("$");
  for(int i=0;i<n;i++){
  	string s;cin >> s;
    s="$"+s;
  	v.push_back(s);
  }
  for(int i=1;i<=n;i++){
    for(int j=m;j>=1;j--){
      bool ok0=0,ok1=0;
      if(i+2<=n && v[i][j]=='R' && v[i+1][j]=='G' && v[i+2][j]=='W') ok0=1;
      if(j+2<=m && v[i][j]=='R' && v[i][j+1]=='G' && v[i][j+2]=='W') ok1=1;
      dp[i][j][0]=dp[i][j][1]=-INF;
      if(ok0){
        dp[i][j][0]=1;
        if(i-1>=1 && j+1<=m) dp[i][j][0]=max(dp[i][j][0],ans[i-1][j+1]+1);
      }
      else dp[i][j][0]=-INF;
      if(ok1){
        dp[i][j][1]=1;
        if(i-1>=1 && j+1<=m) dp[i][j][1]=max(dp[i][j][1],dp[i-1][j+1][1]+1);
        if(i-2>=1 && j+2<=m) dp[i][j][1]=max(dp[i][j][1],dp[i-2][j+2][1]+1);
        if(i-3>=1 && j+3<=m) dp[i][j][1]=max(dp[i][j][1],ans[i-3][j+3]+1);
      }
      else dp[i][j][1]=-INF;
      ans[i][j]=max({ans[i-1][j+1],dp[i][j][0],dp[i][j][1]});
    }
  }
  for(int i=1;i<=n;i++) res+=ans[i][1];
  for(int j=2;j<=m;j++) res+=ans[n][j];
  cout << res << '\n';
}

int32_t main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tc=1;//cin >> tc;
  while(tc--) _();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2448 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2508 KB Output is correct
25 Correct 0 ms 2396 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2508 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 0 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 0 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 0 ms 2508 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 0 ms 2396 KB Output is correct
53 Correct 0 ms 2512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2448 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2508 KB Output is correct
25 Correct 0 ms 2396 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2508 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 0 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 0 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 0 ms 2508 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 0 ms 2396 KB Output is correct
53 Correct 0 ms 2512 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 8 ms 34140 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 6 ms 23292 KB Output is correct
58 Correct 18 ms 27604 KB Output is correct
59 Correct 126 ms 124244 KB Output is correct
60 Correct 131 ms 124012 KB Output is correct
61 Correct 134 ms 123976 KB Output is correct
62 Correct 1 ms 2396 KB Output is correct
63 Correct 114 ms 123388 KB Output is correct
64 Correct 73 ms 123956 KB Output is correct
65 Correct 71 ms 123984 KB Output is correct
66 Correct 87 ms 123984 KB Output is correct
67 Correct 60 ms 123984 KB Output is correct
68 Correct 67 ms 124172 KB Output is correct
69 Correct 73 ms 123988 KB Output is correct
70 Correct 12 ms 27728 KB Output is correct
71 Correct 11 ms 27740 KB Output is correct
72 Correct 11 ms 27760 KB Output is correct
73 Correct 14 ms 27740 KB Output is correct
74 Correct 11 ms 27740 KB Output is correct
75 Correct 11 ms 27840 KB Output is correct
76 Correct 10 ms 27736 KB Output is correct
77 Correct 10 ms 27740 KB Output is correct
78 Correct 10 ms 27736 KB Output is correct
79 Correct 11 ms 28800 KB Output is correct
80 Correct 10 ms 27740 KB Output is correct
81 Correct 10 ms 28764 KB Output is correct
82 Correct 10 ms 27792 KB Output is correct
83 Correct 10 ms 27640 KB Output is correct
84 Correct 10 ms 27740 KB Output is correct
85 Correct 10 ms 27876 KB Output is correct
86 Correct 9 ms 27740 KB Output is correct
87 Correct 10 ms 27760 KB Output is correct
88 Correct 10 ms 27736 KB Output is correct
89 Correct 10 ms 27732 KB Output is correct
90 Correct 11 ms 27812 KB Output is correct