답안 #307901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
307901 2020-09-29T13:57:26 Z HynDuf Dango Maker (JOI18_dango_maker) C++11
100 / 100
269 ms 27132 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, 1, n)
        {
            if (up[i][j]) dp[t][1] = max(dp[t - 1][0], dp[t - 1][1]) + 1;
            else dp[t][1] = 0;
            if (ri[i][j]) dp[t][2] = max(dp[t - 1][0], dp[t - 1][2]) + 1;
            else dp[t][2] = 0;
            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, 1, n)
        {
            if (up[i][j]) dp[t][1] = max(dp[t - 1][0], dp[t - 1][1]) + 1;
            else dp[t][1] = 0;
            if (ri[i][j]) dp[t][2] = max(dp[t - 1][0], dp[t - 1][2]) + 1;
            else dp[t][2] = 0;
            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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 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 0 ms 512 KB Output is correct
8 Correct 0 ms 512 KB Output is correct
9 Correct 0 ms 512 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 416 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 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 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 0 ms 512 KB Output is correct
8 Correct 0 ms 512 KB Output is correct
9 Correct 0 ms 512 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 416 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 640 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 0 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 512 KB Output is correct
25 Correct 0 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 452 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 0 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 0 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 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 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 0 ms 512 KB Output is correct
8 Correct 0 ms 512 KB Output is correct
9 Correct 0 ms 512 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 416 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 640 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 0 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 512 KB Output is correct
25 Correct 0 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 452 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 0 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 0 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 544 KB Output is correct
54 Correct 1 ms 384 KB Output is correct
55 Correct 7 ms 9216 KB Output is correct
56 Correct 1 ms 512 KB Output is correct
57 Correct 7 ms 12160 KB Output is correct
58 Correct 27 ms 7296 KB Output is correct
59 Correct 265 ms 27128 KB Output is correct
60 Correct 269 ms 27000 KB Output is correct
61 Correct 268 ms 27040 KB Output is correct
62 Correct 1 ms 512 KB Output is correct
63 Correct 260 ms 26652 KB Output is correct
64 Correct 206 ms 27000 KB Output is correct
65 Correct 217 ms 26956 KB Output is correct
66 Correct 207 ms 27128 KB Output is correct
67 Correct 204 ms 27024 KB Output is correct
68 Correct 199 ms 27000 KB Output is correct
69 Correct 209 ms 27132 KB Output is correct
70 Correct 19 ms 7296 KB Output is correct
71 Correct 19 ms 7296 KB Output is correct
72 Correct 21 ms 7296 KB Output is correct
73 Correct 19 ms 7296 KB Output is correct
74 Correct 23 ms 7272 KB Output is correct
75 Correct 21 ms 7296 KB Output is correct
76 Correct 19 ms 7296 KB Output is correct
77 Correct 19 ms 7296 KB Output is correct
78 Correct 18 ms 7296 KB Output is correct
79 Correct 20 ms 7304 KB Output is correct
80 Correct 19 ms 7296 KB Output is correct
81 Correct 22 ms 7296 KB Output is correct
82 Correct 21 ms 7296 KB Output is correct
83 Correct 20 ms 7380 KB Output is correct
84 Correct 20 ms 7296 KB Output is correct
85 Correct 19 ms 7296 KB Output is correct
86 Correct 21 ms 7296 KB Output is correct
87 Correct 21 ms 7296 KB Output is correct
88 Correct 19 ms 7296 KB Output is correct
89 Correct 20 ms 7296 KB Output is correct
90 Correct 19 ms 7296 KB Output is correct