Submission #307900

# Submission time Handle Problem Language Result Execution time Memory
307900 2020-09-29T13:54:33 Z HynDuf Dango Maker (JOI18_dango_maker) C++11
100 / 100
295 ms 35960 KB
#include <bits/stdc++.h>

#define task "D"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 3002;
int n, m, dp[N][3];
bool up[N][N], ri[N][N];
string s[N];
int main()
{
#ifdef HynDuf
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cin >> n >> m;
    rep(i, 1, n)
    {
        cin >> s[i];
        s[i] = '0' + s[i];
    }
    rep(i, 1, n) rep(j, 1, m)
    {
        if (i > 1 && i < n) up[i][j] = (s[i][j] == 'G' && s[i - 1][j] == 'R' && s[i + 1][j] == 'W');
        if (j > 1 && j < m) ri[i][j] = (s[i][j] == 'G' && s[i][j - 1] == 'R' && s[i][j + 1] == 'W');
    }
    int ans = 0;
    rep(diag, 2, m)
    {
        int i = 1, j = diag;
        rep(t, 0, n) dp[t][0] = dp[t][1] = dp[t][2] = 0;
        rep(t, 1, n)
        {
            if (up[i][j]) dp[t][1] = max(dp[t - 1][0], dp[t - 1][1]) + 1;
            if (ri[i][j]) dp[t][2] = max(dp[t - 1][0], dp[t - 1][2]) + 1;
            dp[t][0] = max({dp[t - 1][0], dp[t - 1][1], dp[t - 1][2]});
            if (i == n || j == 1)
            {
                ans += max({dp[t][0], dp[t][1], dp[t][2]});
                break;
            }
            i++, j--;
        }
    }
    rep(diag, 2, n)
    {
        int i = diag, j = m;
        rep(t, 0, n) dp[t][0] = dp[t][1] = dp[t][2] = 0;
        rep(t, 1, n)
        {
            if (up[i][j]) dp[t][1] = max(dp[t - 1][0], dp[t - 1][1]) + 1;
            if (ri[i][j]) dp[t][2] = max(dp[t - 1][0], dp[t - 1][2]) + 1;
            dp[t][0] = max({dp[t - 1][0], dp[t - 1][1], dp[t - 1][2]});
            if (i == n || j == 1)
            {
                ans += max({dp[t][0], dp[t][1], dp[t][2]});
                break;
            }
            i++, j--;
        }
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 544 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 1 ms 512 KB Output is correct
44 Correct 1 ms 512 KB Output is correct
45 Correct 1 ms 512 KB Output is correct
46 Correct 1 ms 512 KB Output is correct
47 Correct 1 ms 512 KB Output is correct
48 Correct 1 ms 512 KB Output is correct
49 Correct 1 ms 512 KB Output is correct
50 Correct 1 ms 512 KB Output is correct
51 Correct 1 ms 512 KB Output is correct
52 Correct 1 ms 512 KB Output is correct
53 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 1 ms 512 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 544 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 1 ms 512 KB Output is correct
44 Correct 1 ms 512 KB Output is correct
45 Correct 1 ms 512 KB Output is correct
46 Correct 1 ms 512 KB Output is correct
47 Correct 1 ms 512 KB Output is correct
48 Correct 1 ms 512 KB Output is correct
49 Correct 1 ms 512 KB Output is correct
50 Correct 1 ms 512 KB Output is correct
51 Correct 1 ms 512 KB Output is correct
52 Correct 1 ms 512 KB Output is correct
53 Correct 1 ms 512 KB Output is correct
54 Correct 1 ms 512 KB Output is correct
55 Correct 20 ms 9344 KB Output is correct
56 Correct 1 ms 512 KB Output is correct
57 Correct 13 ms 12288 KB Output is correct
58 Correct 28 ms 8448 KB Output is correct
59 Correct 284 ms 35832 KB Output is correct
60 Correct 279 ms 35832 KB Output is correct
61 Correct 295 ms 35832 KB Output is correct
62 Correct 1 ms 512 KB Output is correct
63 Correct 273 ms 35336 KB Output is correct
64 Correct 234 ms 35960 KB Output is correct
65 Correct 233 ms 35832 KB Output is correct
66 Correct 226 ms 35836 KB Output is correct
67 Correct 222 ms 35832 KB Output is correct
68 Correct 221 ms 35832 KB Output is correct
69 Correct 229 ms 35832 KB Output is correct
70 Correct 22 ms 8320 KB Output is correct
71 Correct 21 ms 8280 KB Output is correct
72 Correct 21 ms 8320 KB Output is correct
73 Correct 22 ms 8320 KB Output is correct
74 Correct 21 ms 8320 KB Output is correct
75 Correct 21 ms 8320 KB Output is correct
76 Correct 23 ms 8448 KB Output is correct
77 Correct 21 ms 8320 KB Output is correct
78 Correct 22 ms 8320 KB Output is correct
79 Correct 22 ms 8320 KB Output is correct
80 Correct 21 ms 8372 KB Output is correct
81 Correct 21 ms 8320 KB Output is correct
82 Correct 21 ms 8320 KB Output is correct
83 Correct 22 ms 8320 KB Output is correct
84 Correct 21 ms 8320 KB Output is correct
85 Correct 21 ms 8320 KB Output is correct
86 Correct 21 ms 8320 KB Output is correct
87 Correct 22 ms 8320 KB Output is correct
88 Correct 21 ms 8320 KB Output is correct
89 Correct 21 ms 8440 KB Output is correct
90 Correct 21 ms 8320 KB Output is correct