답안 #442237

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
442237 2021-07-07T10:25:19 Z Vladth11 Dango Maker (JOI18_dango_maker) C++14
100 / 100
558 ms 143368 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long double, pii> muchie;
typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> OST;

const ll NMAX = 300001;
const ll INF = (1LL << 60);
const ll HALF = (1LL << 59);
const ll MOD = 1000000007;
const ll BLOCK = 318;
const ll base = 31;
const ll nr_of_bits = 21;
const ll LIMIT = 1000;

char mat[3002][3002];
int dp[3002][3002][3];
int n, m;
bool abil[3001][3001][3];

void bagadp(int i, int j){
    while(i >= 1 && i <= n && j >= 1 && j <= m){
        dp[i][j][0] = max({dp[i - 1][j + 1][1], dp[i - 1][j + 1][0], dp[i - 1][j + 1][2]});
        dp[i][j][1] = max({dp[i - 1][j + 1][1], dp[i - 1][j + 1][0]}) + 1;
        dp[i][j][2] = max({dp[i - 1][j + 1][2], dp[i - 1][j + 1][0]}) + 1;
        if(!abil[i][j][1])
            dp[i][j][1] = -2e9;
        if(!abil[i][j][2])
            dp[i][j][2] = -2e9;
        i++;
        j--;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i, j;
    cin >> n >> m;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= m; j++){
            cin >> mat[i][j];
        }
    }
    for(i = 1; i <= n; i++){
        for(j = 1; j <= m; j++){
               abil[i][j][0] = 1;
            if(mat[i][j] != 'G')
                continue;
            if(mat[i][j - 1] == 'R' && mat[i][j + 1] == 'W')
                abil[i][j][1] = 1;
            if(mat[i - 1][j] == 'R' && mat[i + 1][j] == 'W')
                abil[i][j][2] = 1;
        }
    }
    for(j = 1; j <= m; j++){
        bagadp(1, j);
    }
    for(i = 1; i <= n; i++){
        bagadp(i, m);
    }
    int sum = 0;

    for(i = 1; i <= n; i++){
        sum += max({dp[i][1][0], dp[i][1][1], dp[i][1][2]});
    }
    for(i = 2; i <= m; i++){
        sum += max({dp[n][i][0], dp[n][i][1], dp[n][i][2]});
    }
    cout << sum;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 448 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 448 KB Output is correct
45 Correct 1 ms 448 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 448 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 448 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 448 KB Output is correct
45 Correct 1 ms 448 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 448 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 448 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 15 ms 33320 KB Output is correct
56 Correct 1 ms 588 KB Output is correct
57 Correct 12 ms 22572 KB Output is correct
58 Correct 71 ms 26892 KB Output is correct
59 Correct 558 ms 143368 KB Output is correct
60 Correct 547 ms 142512 KB Output is correct
61 Correct 556 ms 142512 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 528 ms 142468 KB Output is correct
64 Correct 527 ms 142656 KB Output is correct
65 Correct 535 ms 142532 KB Output is correct
66 Correct 529 ms 142532 KB Output is correct
67 Correct 491 ms 142560 KB Output is correct
68 Correct 504 ms 142628 KB Output is correct
69 Correct 505 ms 142532 KB Output is correct
70 Correct 57 ms 26764 KB Output is correct
71 Correct 57 ms 26672 KB Output is correct
72 Correct 58 ms 26704 KB Output is correct
73 Correct 57 ms 26668 KB Output is correct
74 Correct 55 ms 26732 KB Output is correct
75 Correct 54 ms 26664 KB Output is correct
76 Correct 59 ms 26708 KB Output is correct
77 Correct 55 ms 26756 KB Output is correct
78 Correct 56 ms 26704 KB Output is correct
79 Correct 55 ms 26744 KB Output is correct
80 Correct 55 ms 26700 KB Output is correct
81 Correct 56 ms 26708 KB Output is correct
82 Correct 59 ms 26748 KB Output is correct
83 Correct 57 ms 26772 KB Output is correct
84 Correct 53 ms 26652 KB Output is correct
85 Correct 55 ms 26656 KB Output is correct
86 Correct 55 ms 26684 KB Output is correct
87 Correct 55 ms 26692 KB Output is correct
88 Correct 54 ms 26748 KB Output is correct
89 Correct 54 ms 26720 KB Output is correct
90 Correct 56 ms 26704 KB Output is correct