Submission #729372

# Submission time Handle Problem Language Result Execution time Memory
729372 2023-04-24T01:52:22 Z Pring Dango Maker (JOI18_dango_maker) C++14
13 / 100
2000 ms 468 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")

#define int long long
typedef pair<int, int> pii;

const int MXN = 3000;
int n, m, ans = 0;
string s[MXN];
vector<vector<pii>> tango;
bitset<MXN> b[MXN];

void GET_TANGO() {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m - 2; j++) {
            if (s[i][j] == 'R' && s[i][j + 1] == 'G' && s[i][j + 2] == 'W') {
                tango.push_back({{i, j}, {i, j + 1}, {i, j + 2}});
            }
            // if (s[i][j] == 'W' && s[i][j + 1] == 'G' && s[i][j + 2] == 'R') {
            //     tango.push_back({{i, j}, {i, j + 1}, {i, j + 2}});
            // }
        }
    }
    for (int j = 0; j < m; j++) {
        for (int i = 0; i < n - 2; i++) {
            if (s[i][j] == 'R' && s[i + 1][j] == 'G' && s[i + 2][j] == 'W') {
                tango.push_back({{i, j}, {i + 1, j}, {i + 2, j}});
            }
            // if (s[i][j] == 'W' && s[i + 1][j] == 'G' && s[i + 2][j] == 'R') {
            //     tango.push_back({{i, j}, {i + 1, j}, {i + 2, j}});
            // }
        }
    }
}

void DFS(int id, int now) {
    if (id == tango.size()) {
        ans = max(ans, now);
        return;
    }
    bool flag = true;
    for (int i = 0; flag && i < 3; i++) {
        if (b[tango[id][i].first][tango[id][i].second]) {
            flag = false;
        }
    }
    if (flag) {
        for (int i = 0; flag && i < 3; i++) {
            b[tango[id][i].first][tango[id][i].second] = true;
        }
        DFS(id + 1, now + 1);
        for (int i = 0; flag && i < 3; i++) {
            b[tango[id][i].first][tango[id][i].second] = false;
        }
    }
    DFS(id + 1, now);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> s[i];
    GET_TANGO();
    // for (auto &i : tango) {
    //     for (auto &j : i) cout << j.first << ' ' << j.second << endl;
    //     cout << endl;
    // }
    DFS(0, 0);
    cout << ans << endl;
    return 0;
}

Compilation message

dango_maker.cpp: In function 'void DFS(long long int, long long int)':
dango_maker.cpp:38:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     if (id == tango.size()) {
      |         ~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 424 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 11 ms 340 KB Output is correct
21 Correct 9 ms 428 KB Output is correct
22 Correct 82 ms 408 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 424 KB Output is correct
26 Correct 1 ms 424 KB Output is correct
27 Execution timed out 2070 ms 340 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 424 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 11 ms 340 KB Output is correct
21 Correct 9 ms 428 KB Output is correct
22 Correct 82 ms 408 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 424 KB Output is correct
26 Correct 1 ms 424 KB Output is correct
27 Execution timed out 2070 ms 340 KB Time limit exceeded
28 Halted 0 ms 0 KB -