답안 #88216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88216 2018-12-04T14:43:13 Z tieunhi Dango Maker (JOI18_dango_maker) C++14
100 / 100
527 ms 178344 KB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define mp make_pair
#define F first
#define S second
#define FOR(i, u, v) for (int i = u; i <= v; i++)
#define FORD(i, v, u) for (int i = v; i >= u; i--)
#define N 3005

using namespace std;

int n, m, dp[N][3], dd[N][N][3], cur;
char c[N][N];
pii a[N];
int solve()
{
    FOR(i, 0, cur)
        FOR(j, 0, 2) dp[i][j] = 0;
    int ans = 0;
    FOR(i, 1, cur)
    {
        dp[i][0] = max({dp[i-1][0], dp[i-1][1], dp[i-1][2]});
        if (dd[a[i].F][a[i].S][1])
            dp[i][1] = max(dp[i-1][0], dp[i-1][1]) + 1;
        if (dd[a[i].F][a[i].S][2])
            dp[i][2] = max(dp[i-1][0], dp[i-1][2]) + 1;

        ans = max({ans, dp[i][0], dp[i][1], dp[i][2]});
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("INP.TXT", "r", stdin);
    cin >> n >> m;
    FOR(i, 1, n)
        FOR(j, 1, m) cin >> c[i][j];
    FOR(i, 1, n)
        FOR(j, 1, m)
        {
            if (c[i][j-1] == 'R' && c[i][j] == 'G' && c[i][j+1] == 'W')
                dd[i][j][1] = 1;
            if (c[i-1][j] == 'R' && c[i][j] == 'G' && c[i+1][j] == 'W')
                dd[i][j][2] = 1;
        }
    int res = 0;

    FOR(i, 2, n+m)
    {
        cur = 0;
        FOR(j, 1, n)
            if (i - j > 0 && i - j <= m) a[++cur] = mp(j, i-j);
        res += solve();
    }
    cout <<res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 532 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 612 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 3 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 2 ms 844 KB Output is correct
16 Correct 2 ms 844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 532 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 612 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 3 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 2 ms 844 KB Output is correct
16 Correct 2 ms 844 KB Output is correct
17 Correct 2 ms 844 KB Output is correct
18 Correct 2 ms 844 KB Output is correct
19 Correct 2 ms 844 KB Output is correct
20 Correct 2 ms 844 KB Output is correct
21 Correct 2 ms 844 KB Output is correct
22 Correct 2 ms 844 KB Output is correct
23 Correct 2 ms 844 KB Output is correct
24 Correct 2 ms 844 KB Output is correct
25 Correct 2 ms 844 KB Output is correct
26 Correct 2 ms 844 KB Output is correct
27 Correct 2 ms 844 KB Output is correct
28 Correct 2 ms 844 KB Output is correct
29 Correct 2 ms 844 KB Output is correct
30 Correct 2 ms 844 KB Output is correct
31 Correct 2 ms 848 KB Output is correct
32 Correct 2 ms 852 KB Output is correct
33 Correct 2 ms 856 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 864 KB Output is correct
36 Correct 2 ms 996 KB Output is correct
37 Correct 2 ms 996 KB Output is correct
38 Correct 2 ms 996 KB Output is correct
39 Correct 2 ms 996 KB Output is correct
40 Correct 2 ms 996 KB Output is correct
41 Correct 2 ms 996 KB Output is correct
42 Correct 3 ms 996 KB Output is correct
43 Correct 2 ms 996 KB Output is correct
44 Correct 2 ms 996 KB Output is correct
45 Correct 2 ms 996 KB Output is correct
46 Correct 2 ms 996 KB Output is correct
47 Correct 3 ms 996 KB Output is correct
48 Correct 2 ms 996 KB Output is correct
49 Correct 3 ms 996 KB Output is correct
50 Correct 2 ms 996 KB Output is correct
51 Correct 3 ms 1056 KB Output is correct
52 Correct 2 ms 1056 KB Output is correct
53 Correct 2 ms 1056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 532 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 612 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 3 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 2 ms 844 KB Output is correct
16 Correct 2 ms 844 KB Output is correct
17 Correct 2 ms 844 KB Output is correct
18 Correct 2 ms 844 KB Output is correct
19 Correct 2 ms 844 KB Output is correct
20 Correct 2 ms 844 KB Output is correct
21 Correct 2 ms 844 KB Output is correct
22 Correct 2 ms 844 KB Output is correct
23 Correct 2 ms 844 KB Output is correct
24 Correct 2 ms 844 KB Output is correct
25 Correct 2 ms 844 KB Output is correct
26 Correct 2 ms 844 KB Output is correct
27 Correct 2 ms 844 KB Output is correct
28 Correct 2 ms 844 KB Output is correct
29 Correct 2 ms 844 KB Output is correct
30 Correct 2 ms 844 KB Output is correct
31 Correct 2 ms 848 KB Output is correct
32 Correct 2 ms 852 KB Output is correct
33 Correct 2 ms 856 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 864 KB Output is correct
36 Correct 2 ms 996 KB Output is correct
37 Correct 2 ms 996 KB Output is correct
38 Correct 2 ms 996 KB Output is correct
39 Correct 2 ms 996 KB Output is correct
40 Correct 2 ms 996 KB Output is correct
41 Correct 2 ms 996 KB Output is correct
42 Correct 3 ms 996 KB Output is correct
43 Correct 2 ms 996 KB Output is correct
44 Correct 2 ms 996 KB Output is correct
45 Correct 2 ms 996 KB Output is correct
46 Correct 2 ms 996 KB Output is correct
47 Correct 3 ms 996 KB Output is correct
48 Correct 2 ms 996 KB Output is correct
49 Correct 3 ms 996 KB Output is correct
50 Correct 2 ms 996 KB Output is correct
51 Correct 3 ms 1056 KB Output is correct
52 Correct 2 ms 1056 KB Output is correct
53 Correct 2 ms 1056 KB Output is correct
54 Correct 2 ms 1056 KB Output is correct
55 Correct 23 ms 10292 KB Output is correct
56 Correct 3 ms 10292 KB Output is correct
57 Correct 21 ms 14044 KB Output is correct
58 Correct 67 ms 20592 KB Output is correct
59 Correct 523 ms 125536 KB Output is correct
60 Correct 527 ms 134592 KB Output is correct
61 Correct 508 ms 143276 KB Output is correct
62 Correct 2 ms 143276 KB Output is correct
63 Correct 527 ms 151856 KB Output is correct
64 Correct 451 ms 160504 KB Output is correct
65 Correct 435 ms 169376 KB Output is correct
66 Correct 445 ms 178344 KB Output is correct
67 Correct 366 ms 178344 KB Output is correct
68 Correct 387 ms 178344 KB Output is correct
69 Correct 408 ms 178344 KB Output is correct
70 Correct 57 ms 178344 KB Output is correct
71 Correct 58 ms 178344 KB Output is correct
72 Correct 56 ms 178344 KB Output is correct
73 Correct 50 ms 178344 KB Output is correct
74 Correct 58 ms 178344 KB Output is correct
75 Correct 57 ms 178344 KB Output is correct
76 Correct 51 ms 178344 KB Output is correct
77 Correct 50 ms 178344 KB Output is correct
78 Correct 51 ms 178344 KB Output is correct
79 Correct 51 ms 178344 KB Output is correct
80 Correct 58 ms 178344 KB Output is correct
81 Correct 57 ms 178344 KB Output is correct
82 Correct 51 ms 178344 KB Output is correct
83 Correct 50 ms 178344 KB Output is correct
84 Correct 50 ms 178344 KB Output is correct
85 Correct 51 ms 178344 KB Output is correct
86 Correct 49 ms 178344 KB Output is correct
87 Correct 50 ms 178344 KB Output is correct
88 Correct 49 ms 178344 KB Output is correct
89 Correct 50 ms 178344 KB Output is correct
90 Correct 47 ms 178344 KB Output is correct