답안 #197004

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197004 2020-01-18T04:20:52 Z combi1k1 Dango Maker (JOI18_dango_maker) C++14
100 / 100
326 ms 18172 KB
#include<bits/stdc++.h>

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 3005;

typedef pair<int,int>   ii;

char a[N][N];
int  f[N][2][2];

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n;  cin >> n;
    int m;  cin >> m;

    for(int i = 1 ; i <= n ; ++i)
    for(int j = 1 ; j <= m ; ++j)
        cin >> a[i][j];

    int ans = 0;

    for(int d = 1 ; d < n + m ; ++d)    {
        int r = 1;
        int c = d;

        if (c > m)  r += (c - m),   c = m;
        if (r > n)  c += (r - n),   r = n;

        int len = min(n - r + 1,c);

        for(int i = 1 ; i <= len ; ++i)
            f[i][0][0] = f[i][0][1] = 0,
            f[i][1][0] = f[i][1][1] = 0;

        for(int i = 1 ; i <= len ; ++i, ++r, --c)   {
            for(int j = 0 ; j < 2 ; ++j)
            for(int k = 0 ; k < 2 ; ++k)
                f[i][k][0] = max(f[i][k][0],f[i - 1][j][k]);

            if (a[r][c] == 'R') {
                if (a[r + 1][c] == 'G' && a[r + 2][c] == 'W')   {
                    f[i][0][1] = max(f[i][0][1],f[i][0][0] + 1);
                    f[i][1][1] = max(f[i][1][1],f[i][1][0] + 1);
                }
                if (a[r][c + 1] == 'G' && a[r][c + 2] == 'W')
                    f[i][0][0] = max(f[i][0][0],f[i - 1][0][0] + 1);
            }
        }
        int cur = 0;

        for(int i = 1 ; i <= len ; ++i)
        for(int j = 0 ; j < 2 ; ++j)
        for(int k = 0 ; k < 2 ; ++k)
            if (cur < f[i][j][k])
                cur = f[i][j][k];

        ans += cur;
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 248 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 1 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 248 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 1 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 9 ms 380 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 380 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 248 KB Output is correct
31 Correct 7 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 5 ms 348 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
39 Correct 3 ms 376 KB Output is correct
40 Correct 2 ms 504 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 248 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 1 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 9 ms 380 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 380 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 248 KB Output is correct
31 Correct 7 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 5 ms 348 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
39 Correct 3 ms 376 KB Output is correct
40 Correct 2 ms 504 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
54 Correct 3 ms 376 KB Output is correct
55 Correct 7 ms 9208 KB Output is correct
56 Correct 3 ms 376 KB Output is correct
57 Correct 7 ms 6264 KB Output is correct
58 Correct 37 ms 4272 KB Output is correct
59 Correct 324 ms 18172 KB Output is correct
60 Correct 325 ms 18040 KB Output is correct
61 Correct 326 ms 18172 KB Output is correct
62 Correct 2 ms 376 KB Output is correct
63 Correct 315 ms 17980 KB Output is correct
64 Correct 257 ms 18080 KB Output is correct
65 Correct 256 ms 18080 KB Output is correct
66 Correct 258 ms 18168 KB Output is correct
67 Correct 254 ms 18168 KB Output is correct
68 Correct 260 ms 18084 KB Output is correct
69 Correct 276 ms 18120 KB Output is correct
70 Correct 33 ms 4472 KB Output is correct
71 Correct 33 ms 4408 KB Output is correct
72 Correct 33 ms 4344 KB Output is correct
73 Correct 35 ms 4344 KB Output is correct
74 Correct 30 ms 4264 KB Output is correct
75 Correct 31 ms 4260 KB Output is correct
76 Correct 30 ms 4216 KB Output is correct
77 Correct 33 ms 4344 KB Output is correct
78 Correct 32 ms 4344 KB Output is correct
79 Correct 31 ms 4388 KB Output is correct
80 Correct 31 ms 4344 KB Output is correct
81 Correct 32 ms 4216 KB Output is correct
82 Correct 31 ms 4344 KB Output is correct
83 Correct 31 ms 4380 KB Output is correct
84 Correct 32 ms 4216 KB Output is correct
85 Correct 32 ms 4348 KB Output is correct
86 Correct 34 ms 4216 KB Output is correct
87 Correct 35 ms 4220 KB Output is correct
88 Correct 34 ms 4216 KB Output is correct
89 Correct 33 ms 4344 KB Output is correct
90 Correct 33 ms 4216 KB Output is correct