답안 #762643

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762643 2023-06-21T15:18:05 Z sysia Dango Maker (JOI18_dango_maker) C++17
100 / 100
817 ms 18588 KB
//Sylwia Sapkowska
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;

void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << "'" << x << "'";}
void __print(const char *x) {cerr << '"' << x << '"';}
void __print(const string &x) {cerr << '"' << x << '"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<int, int> T;

void solve(){
    int n, m; cin >> n >> m;
    vector a(n+1, vector<char>(m+1));
    for (int i = 1; i<=n; i++){
        for (int j = 1; j<=m; j++){
            cin >> a[i][j];
        }
    }

    auto ok = [&](int i, int j, char c){
        return (i >= 1 && j >= 1 && i <= n && j <= m && a[i][j] == c);
    };
    //0 - obojetne jaki kierunek (oba)
    //1 - w prawo
    //2 - w gore
    int ans = 0;
    // vector dp(n+m+1, vector<vector<int>>(n+3, vector<int>(3)));
    //usunac stan diagonal bo nie uzywam go lol
    for (int diag = 2; diag <= n+m; diag++){
        int curr = 0;
        debug(diag);
        vector dp(n+3, vector<int>(3));
        for (int i = n; i>=1; i--){
            int j = diag-i;
            if (j < 1 || j > m) continue;
            dp[i][1] = max(dp[i+1][1], dp[i+2][0]);
            dp[i][2] = max(dp[i+1][2], dp[i+2][0]);
            if (ok(i, j, 'G') && ok(i-1, j, 'R') && ok(i+1, j, 'W')){
                // dp[diag][i][2] = max(dp[diag][i+1][2] + 1, dp[diag][i+2][0] + 1);
                dp[i][2]++;
            }
            if (ok(i, j, 'G') && ok(i, j-1, 'R') && ok(i, j+1, 'W')){
                dp[i][1]++;
            }
            dp[i][0] = max(dp[i][1], dp[i][2]);
            debug(i, j, dp[i][1], dp[i][2]);
            curr = max(curr, dp[i][0]);
        }
        ans += curr;
    }
    cout << ans << "\n";
}

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

    int t = 1;
    //cin >> t;
    while (t--) solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 320 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 324 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 320 KB Output is correct
30 Correct 0 ms 320 KB Output is correct
31 Correct 1 ms 320 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 316 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 316 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 320 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 324 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 320 KB Output is correct
30 Correct 0 ms 320 KB Output is correct
31 Correct 1 ms 320 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 316 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 316 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 259 ms 640 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 113 ms 468 KB Output is correct
58 Correct 77 ms 2364 KB Output is correct
59 Correct 817 ms 18324 KB Output is correct
60 Correct 808 ms 18340 KB Output is correct
61 Correct 810 ms 18300 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 807 ms 17588 KB Output is correct
64 Correct 736 ms 18428 KB Output is correct
65 Correct 750 ms 18284 KB Output is correct
66 Correct 749 ms 18588 KB Output is correct
67 Correct 728 ms 18228 KB Output is correct
68 Correct 755 ms 18232 KB Output is correct
69 Correct 755 ms 18252 KB Output is correct
70 Correct 70 ms 2260 KB Output is correct
71 Correct 77 ms 2376 KB Output is correct
72 Correct 71 ms 2260 KB Output is correct
73 Correct 69 ms 2260 KB Output is correct
74 Correct 73 ms 2352 KB Output is correct
75 Correct 71 ms 2260 KB Output is correct
76 Correct 72 ms 2260 KB Output is correct
77 Correct 82 ms 2376 KB Output is correct
78 Correct 76 ms 2368 KB Output is correct
79 Correct 73 ms 2360 KB Output is correct
80 Correct 76 ms 2260 KB Output is correct
81 Correct 69 ms 2260 KB Output is correct
82 Correct 73 ms 2360 KB Output is correct
83 Correct 71 ms 2356 KB Output is correct
84 Correct 70 ms 2368 KB Output is correct
85 Correct 71 ms 2384 KB Output is correct
86 Correct 72 ms 2364 KB Output is correct
87 Correct 71 ms 2364 KB Output is correct
88 Correct 70 ms 2260 KB Output is correct
89 Correct 74 ms 2368 KB Output is correct
90 Correct 69 ms 2364 KB Output is correct