Submission #544126

# Submission time Handle Problem Language Result Execution time Memory
544126 2022-04-01T05:53:19 Z Cookie197 Dango Maker (JOI18_dango_maker) C++17
100 / 100
708 ms 44548 KB
// Cookie197 
// the people who invented competitive programming must be ******* crazy
// why am i still here suffering while i can do something else more valuable?
// WHY???
//#pragma GCC optimize("O4,unroll-loops,no-stack-protector")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<string>
#include<iomanip>
#include<math.h>
#include<unordered_map>
#include<numeric>
#include<random>
using namespace std;
#define Why_does_competitive_programming_even_exist ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define pii pair<ll,ll>
#define pdd pair<double ,double>
#define mp make_pair
//#define mod 998244353
#define mod 1000000007
#define endl "\n"
#define inf (ll)5e18
#define out(x) cout << #x << " = " << x <<endl;
#define out2(a,b) cout<< #a << "[" << b << "]" << " = " << a[b] << endl;
#define outp(x) cout << #x << " first = " << x.first << "  second = " << x.second << endl

// 以斜排來看,不論怎麼選,RGW都是「第i斜排,第i+1斜排,第i+2斜排」
// 所以,不同斜排(不同i)的串,是完全獨立的
// 對每個斜排,都做一個dp,再把每一斜排的答案加起來

// 對每個斜排,由左下到右上,考慮G
// 每個G可以選擇:不選(0) 選上下i-1,i,i+1(1) 選左右j-1,j,j+1(2)
int dp[3005][3];
int arr[3005][3005];
int n,m,rcnt;
vector<pii> R;
int ans;

signed main(){
    cin>>n>>m;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            char c; cin>>c;
            if (c=='R') arr[i][j] = 1;
            if (c=='G') arr[i][j] = 2;
            if (c=='W') arr[i][j] = 3;
        }
    }

    for (int z=2;z<=n+m;z++){
        int now = 0;
        for (int i=1;i<=n;i++) dp[i][0] = dp[i][1] = dp[i][2] = 0;
        for (int i=1;i<=n;i++){
            int j = z-i;
            if (j<=0 || j>m) continue;

            dp[i][0] = max(dp[i-1][0], max(dp[i-1][1], dp[i-1][2]));
            if (arr[i][j] == 2 && arr[i-1][j] == 1 && arr[i+1][j] == 3){
                dp[i][1] = max(dp[i-1][0], dp[i-1][1]) + 1;
            }
            if (arr[i][j] == 2 && arr[i][j-1] == 1 && arr[i][j+1] == 3){
                dp[i][2] = max(dp[i-1][0], dp[i-1][2]) + 1;
            }

            now = max(now, max(max(dp[i][0], dp[i][1]),dp[i][2]));
        }
        ans += now;
    }

    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 312 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 304 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 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 0 ms 304 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 1 ms 308 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 308 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 308 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 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 312 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 304 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 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 0 ms 304 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 1 ms 308 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 308 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 308 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 1 ms 212 KB Output is correct
55 Correct 23 ms 12416 KB Output is correct
56 Correct 2 ms 320 KB Output is correct
57 Correct 12 ms 8384 KB Output is correct
58 Correct 80 ms 9088 KB Output is correct
59 Correct 708 ms 44548 KB Output is correct
60 Correct 704 ms 44540 KB Output is correct
61 Correct 698 ms 44428 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 707 ms 44308 KB Output is correct
64 Correct 676 ms 44428 KB Output is correct
65 Correct 677 ms 44432 KB Output is correct
66 Correct 673 ms 44376 KB Output is correct
67 Correct 594 ms 44468 KB Output is correct
68 Correct 593 ms 44424 KB Output is correct
69 Correct 624 ms 44428 KB Output is correct
70 Correct 78 ms 9148 KB Output is correct
71 Correct 76 ms 9200 KB Output is correct
72 Correct 75 ms 9176 KB Output is correct
73 Correct 74 ms 9208 KB Output is correct
74 Correct 76 ms 9208 KB Output is correct
75 Correct 78 ms 9196 KB Output is correct
76 Correct 76 ms 9200 KB Output is correct
77 Correct 77 ms 9112 KB Output is correct
78 Correct 76 ms 9208 KB Output is correct
79 Correct 78 ms 9088 KB Output is correct
80 Correct 76 ms 9172 KB Output is correct
81 Correct 74 ms 9204 KB Output is correct
82 Correct 78 ms 9128 KB Output is correct
83 Correct 78 ms 9104 KB Output is correct
84 Correct 76 ms 9140 KB Output is correct
85 Correct 76 ms 9164 KB Output is correct
86 Correct 82 ms 9152 KB Output is correct
87 Correct 74 ms 9112 KB Output is correct
88 Correct 80 ms 9304 KB Output is correct
89 Correct 75 ms 9196 KB Output is correct
90 Correct 77 ms 9172 KB Output is correct