Submission #503232

# Submission time Handle Problem Language Result Execution time Memory
503232 2022-01-07T14:43:13 Z Kirill_Maglysh Dango Maker (JOI18_dango_maker) C++17
0 / 100
193 ms 262148 KB
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define printLn(n) cout << n << '\n'

using namespace std;

vector<vector<char>> field(3000 + 2, vector<char>(3000 + 2, '#'));
vector<vector<vector<short>>> dp(3000 + 2, vector<vector<short>>(3000 + 2, vector<short>(3, 0)));

const short EMPTY = 0;
const short HORIZONTAL = 1;
const short VERTICAL = 2;

short readLL();

string readStr();

void resolve();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    resolve();

    return 0;
}

void resolve() {
    short height = readLL();
    short width = readLL();
    for (short i = 1; i <= height; ++i) {
        string str = readStr();
        for (short j = 1; j <= width; ++j) {
            field[i][j] = str[j - 1];
        }
    }

    int res = 0;
    for (short i = 1; i <= height; ++i) {
        for (short j = 1; j <= width; ++j) {
            dp[i][j][EMPTY] = max(dp[i - 1][j + 1][EMPTY], max(dp[i - 1][j + 1][HORIZONTAL], dp[i - 1][j + 1][VERTICAL]));

            if (field[i - 1][j] == 'R' && field[i][j] == 'G' && field[i + 1][j] == 'W') {
                dp[i][j][VERTICAL] = 1 + max(dp[i - 1][j + 1][VERTICAL], dp[i - 1][j + 1][EMPTY]);
            }

            if (field[i][j - 1] == 'R' && field[i][j] == 'G' && field[i][j + 1] == 'W') {
                dp[i][j][HORIZONTAL] = 1 + max(dp[i - 1][j + 1][HORIZONTAL], dp[i - 1][j + 1][EMPTY]);
            }

            if (i == height || j == 1) {
                res += max(dp[i][j][EMPTY], max(dp[i][j][HORIZONTAL], dp[i][j][VERTICAL]));
            }
        }
    }

    printLn(res);
}

short readLL() {
    short num;
    cin >> num;
    return num;
}

string readStr() {
    string num;
    cin >> num;
    return num;
}
# Verdict Execution time Memory Grader output
1 Runtime error 193 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 193 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 193 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -