Submission #1100518

# Submission time Handle Problem Language Result Execution time Memory
1100518 2024-10-14T07:27:28 Z underwaterkillerwhale Dango Maker (JOI18_dango_maker) C++17
100 / 100
117 ms 53420 KB
//#include"holiday.h"
#include <bits/stdc++.h>
#define ll long long
#define rep(i,m,n) for(int i=(m); i<=(n); i++)
#define reb(i,m,n) for(int i=(m); i>=(n); i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair
#define fs first
#define se second
#define bit(msk, i) ((msk >> i) & 1)
#define iter(id, v) for(auto id : v)
#define pb push_back
#define SZ(v) (ll)v.size()
#define ALL(v) v.begin(),v.end()

using namespace std;

mt19937_64 rd(chrono :: steady_clock :: now ().time_since_epoch().count());
ll Rand (ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rd); }

const int N = 3e3 + 7;
int Mod = 2e9 + 7;///lon
const ll INF = 2e9;
const ll BASE = 137;
const int szBL = 450;

int n, m;
char a[N][N];
int dp[N][N];

void solution () {
    cin >> n >> m;
    rep (i, 1, n) {
        string s;
        cin >> s;
        rep (j, 1, m) a[i][j] = s[j - 1];
    }
    auto dangoN = [&] (int i, int j) {
        return a[i][j - 1] == 'R' && a[i][j] == 'G' && a[i][j + 1] == 'W';
    };
    auto dangoD = [&] (int i, int j) {
        return a[i - 1][j] == 'R' && a[i][j] == 'G' && a[i + 1][j] == 'W';
    };
    int res = 0;
    rep (T, 1, n + m) {
        rep (i, 1, n) {
            int j = T - i;
            if (j > m || j <= 0) {
                rep (k, 0, 2) dp[i][k] = dp[i - 1][k];
                continue;
            }
            dp[i][0] = max({dp[i - 1][1], dp[i - 1][0], dp[i - 1][2]});
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) + dangoN(i, j);
            dp[i][2] = max(dp[i - 1][0], dp[i - 1][2]) + dangoD(i, j);
        }
        res += max({dp[n][0], dp[n][1], dp[n][2]});
    }
    cout << res <<"\n";
}

#define file(name) freopen(name".inp","r",stdin); \
freopen(name".out","w",stdout);
int main () {
//    file("c");
    ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int num_Test = 1;
//    cin >> num_Test;
    while (num_Test--)
        solution();
}
/*
no bug challenge +10

5 5
01101
10001
00110
10101
00100
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2552 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2384 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2384 KB Output is correct
30 Correct 1 ms 2384 KB Output is correct
31 Correct 1 ms 2384 KB Output is correct
32 Correct 1 ms 2384 KB Output is correct
33 Correct 1 ms 2384 KB Output is correct
34 Correct 1 ms 2384 KB Output is correct
35 Correct 1 ms 2384 KB Output is correct
36 Correct 1 ms 2384 KB Output is correct
37 Correct 1 ms 2384 KB Output is correct
38 Correct 1 ms 2384 KB Output is correct
39 Correct 1 ms 2384 KB Output is correct
40 Correct 1 ms 2384 KB Output is correct
41 Correct 1 ms 2384 KB Output is correct
42 Correct 1 ms 2552 KB Output is correct
43 Correct 1 ms 2384 KB Output is correct
44 Correct 1 ms 2384 KB Output is correct
45 Correct 1 ms 2384 KB Output is correct
46 Correct 1 ms 2384 KB Output is correct
47 Correct 1 ms 2384 KB Output is correct
48 Correct 1 ms 2384 KB Output is correct
49 Correct 1 ms 2384 KB Output is correct
50 Correct 1 ms 2384 KB Output is correct
51 Correct 1 ms 2384 KB Output is correct
52 Correct 1 ms 2384 KB Output is correct
53 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2552 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2384 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2384 KB Output is correct
30 Correct 1 ms 2384 KB Output is correct
31 Correct 1 ms 2384 KB Output is correct
32 Correct 1 ms 2384 KB Output is correct
33 Correct 1 ms 2384 KB Output is correct
34 Correct 1 ms 2384 KB Output is correct
35 Correct 1 ms 2384 KB Output is correct
36 Correct 1 ms 2384 KB Output is correct
37 Correct 1 ms 2384 KB Output is correct
38 Correct 1 ms 2384 KB Output is correct
39 Correct 1 ms 2384 KB Output is correct
40 Correct 1 ms 2384 KB Output is correct
41 Correct 1 ms 2384 KB Output is correct
42 Correct 1 ms 2552 KB Output is correct
43 Correct 1 ms 2384 KB Output is correct
44 Correct 1 ms 2384 KB Output is correct
45 Correct 1 ms 2384 KB Output is correct
46 Correct 1 ms 2384 KB Output is correct
47 Correct 1 ms 2384 KB Output is correct
48 Correct 1 ms 2384 KB Output is correct
49 Correct 1 ms 2384 KB Output is correct
50 Correct 1 ms 2384 KB Output is correct
51 Correct 1 ms 2384 KB Output is correct
52 Correct 1 ms 2384 KB Output is correct
53 Correct 1 ms 2384 KB Output is correct
54 Correct 1 ms 2384 KB Output is correct
55 Correct 18 ms 44564 KB Output is correct
56 Correct 1 ms 2552 KB Output is correct
57 Correct 9 ms 33364 KB Output is correct
58 Correct 13 ms 17748 KB Output is correct
59 Correct 112 ms 53356 KB Output is correct
60 Correct 110 ms 53380 KB Output is correct
61 Correct 117 ms 53332 KB Output is correct
62 Correct 1 ms 2388 KB Output is correct
63 Correct 109 ms 52980 KB Output is correct
64 Correct 78 ms 53352 KB Output is correct
65 Correct 77 ms 53344 KB Output is correct
66 Correct 74 ms 53380 KB Output is correct
67 Correct 72 ms 53324 KB Output is correct
68 Correct 73 ms 53360 KB Output is correct
69 Correct 84 ms 53420 KB Output is correct
70 Correct 10 ms 17748 KB Output is correct
71 Correct 9 ms 17744 KB Output is correct
72 Correct 10 ms 17912 KB Output is correct
73 Correct 9 ms 17960 KB Output is correct
74 Correct 10 ms 17748 KB Output is correct
75 Correct 9 ms 17748 KB Output is correct
76 Correct 9 ms 17748 KB Output is correct
77 Correct 9 ms 17748 KB Output is correct
78 Correct 10 ms 17976 KB Output is correct
79 Correct 12 ms 17912 KB Output is correct
80 Correct 11 ms 17748 KB Output is correct
81 Correct 12 ms 18004 KB Output is correct
82 Correct 9 ms 17748 KB Output is correct
83 Correct 9 ms 17956 KB Output is correct
84 Correct 10 ms 17760 KB Output is correct
85 Correct 9 ms 17960 KB Output is correct
86 Correct 9 ms 17748 KB Output is correct
87 Correct 9 ms 17748 KB Output is correct
88 Correct 9 ms 17764 KB Output is correct
89 Correct 10 ms 17956 KB Output is correct
90 Correct 10 ms 17748 KB Output is correct