Submission #680469

# Submission time Handle Problem Language Result Execution time Memory
680469 2023-01-10T23:55:09 Z Neos Dango Maker (JOI18_dango_maker) C++14
33 / 100
2000 ms 32472 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) (int)x.size()
#define getBit(x, i) ((x) >> (i) & 1)
#define rep(i, begin, end) for (ll i = (begin); i <= (end); i++)
#define rrep(i, begin, end) for (ll i = (begin); i >= (end); i--)

typedef long long ll;
typedef pair<int, int> ii;

template <class T>
bool minimize(T &a, const T &b) {
    if(a > b) {a = b; return 1;}
    return 0;
}
template <class T>
bool maximize(T &a, const T &b) {
    if(a < b) {a = b; return 1;}
    return 0;
}

const int N = 3e3 + 7, M = 1e6 + 7, oo = 2e9;

int n, m, tot, sz, match[M], mark[N][N];
string a[N];
bool vis[M];
vector<int> adj[M];

int g(int x, int y) {
    if (mark[x][y]) return mark[x][y];
    return mark[x][y] = ++sz;
}

int mcbm(int u) {
    if (vis[u]) return 0;
    vis[u] = 1;
    for (int v: adj[u]) {
        if (match[v] == -1 || mcbm(match[v])) {
            match[v] = u;
            return 1;
        }
    }
    return 0;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    cin >> n >> m;
    rep(i, 1, n) cin >> a[i], a[i] = ' ' + a[i];
    rep(i, 1, n) rep(j, 1, m) {
        if (j + 2 <= m) tot += (a[i].substr(j, 3) == "RGW");
        if (i + 2 <= n) tot += (a[i][j] == 'R' && a[i + 1][j] == 'G' && a[i + 2][j] == 'W');
    }
    rep(i1, 1, n) rep(j1, 1, m) rep(i2, 1, n) rep(j2, 1, m) {
        if (!(i1 + j1 == i2 + j2)) continue;
        // (i1, j1) right | (i2, j2) down
        if (j1 + 2 <= m && i2 + 2 <= n) {
            if (!(ii(i1, j1) == ii(i2, j2) || ii(i1, j1 + 1) == ii(i2 + 1, j2) || ii(i1, j1 + 2) == ii(i2 + 2, j2)))
                continue;
            if (a[i1].substr(j1, 3) == "RGW" && a[i2][j2] == 'R' && a[i2 + 1][j2] == 'G' && a[i2 + 2][j2] == 'W') {
                adj[g(i1, j1)].pb(tot + g(i2, j2));
            }
        }
    }

    int cnt = 0;
    memset(match, -1, sizeof match);
    rep(i, 1, tot + sz) {
        memset(vis, 0, sizeof vis);
        cnt += mcbm(i);
    }
    cout << tot - cnt;
}

# Verdict Execution time Memory Grader output
1 Correct 14 ms 27732 KB Output is correct
2 Correct 13 ms 27780 KB Output is correct
3 Correct 13 ms 27776 KB Output is correct
4 Correct 14 ms 27732 KB Output is correct
5 Correct 13 ms 27700 KB Output is correct
6 Correct 14 ms 28724 KB Output is correct
7 Correct 14 ms 28716 KB Output is correct
8 Correct 14 ms 28748 KB Output is correct
9 Correct 13 ms 28756 KB Output is correct
10 Correct 13 ms 28756 KB Output is correct
11 Correct 15 ms 28796 KB Output is correct
12 Correct 16 ms 28804 KB Output is correct
13 Correct 16 ms 28788 KB Output is correct
14 Correct 14 ms 28756 KB Output is correct
15 Correct 13 ms 28756 KB Output is correct
16 Correct 13 ms 28884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 27732 KB Output is correct
2 Correct 13 ms 27780 KB Output is correct
3 Correct 13 ms 27776 KB Output is correct
4 Correct 14 ms 27732 KB Output is correct
5 Correct 13 ms 27700 KB Output is correct
6 Correct 14 ms 28724 KB Output is correct
7 Correct 14 ms 28716 KB Output is correct
8 Correct 14 ms 28748 KB Output is correct
9 Correct 13 ms 28756 KB Output is correct
10 Correct 13 ms 28756 KB Output is correct
11 Correct 15 ms 28796 KB Output is correct
12 Correct 16 ms 28804 KB Output is correct
13 Correct 16 ms 28788 KB Output is correct
14 Correct 14 ms 28756 KB Output is correct
15 Correct 13 ms 28756 KB Output is correct
16 Correct 13 ms 28884 KB Output is correct
17 Correct 13 ms 28756 KB Output is correct
18 Correct 13 ms 28760 KB Output is correct
19 Correct 14 ms 28756 KB Output is correct
20 Correct 14 ms 28884 KB Output is correct
21 Correct 16 ms 28780 KB Output is correct
22 Correct 15 ms 28772 KB Output is correct
23 Correct 14 ms 28736 KB Output is correct
24 Correct 17 ms 28756 KB Output is correct
25 Correct 14 ms 27760 KB Output is correct
26 Correct 15 ms 27852 KB Output is correct
27 Correct 15 ms 28836 KB Output is correct
28 Correct 16 ms 28844 KB Output is correct
29 Correct 17 ms 28812 KB Output is correct
30 Correct 15 ms 28756 KB Output is correct
31 Correct 15 ms 28776 KB Output is correct
32 Correct 13 ms 28756 KB Output is correct
33 Correct 16 ms 28780 KB Output is correct
34 Correct 18 ms 28756 KB Output is correct
35 Correct 18 ms 28756 KB Output is correct
36 Correct 16 ms 28776 KB Output is correct
37 Correct 16 ms 28756 KB Output is correct
38 Correct 16 ms 28804 KB Output is correct
39 Correct 15 ms 28796 KB Output is correct
40 Correct 16 ms 28784 KB Output is correct
41 Correct 16 ms 28716 KB Output is correct
42 Correct 15 ms 28788 KB Output is correct
43 Correct 15 ms 28840 KB Output is correct
44 Correct 17 ms 28768 KB Output is correct
45 Correct 15 ms 28836 KB Output is correct
46 Correct 15 ms 28780 KB Output is correct
47 Correct 16 ms 28792 KB Output is correct
48 Correct 15 ms 28772 KB Output is correct
49 Correct 15 ms 28796 KB Output is correct
50 Correct 14 ms 28756 KB Output is correct
51 Correct 15 ms 28772 KB Output is correct
52 Correct 18 ms 28756 KB Output is correct
53 Correct 17 ms 28756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 27732 KB Output is correct
2 Correct 13 ms 27780 KB Output is correct
3 Correct 13 ms 27776 KB Output is correct
4 Correct 14 ms 27732 KB Output is correct
5 Correct 13 ms 27700 KB Output is correct
6 Correct 14 ms 28724 KB Output is correct
7 Correct 14 ms 28716 KB Output is correct
8 Correct 14 ms 28748 KB Output is correct
9 Correct 13 ms 28756 KB Output is correct
10 Correct 13 ms 28756 KB Output is correct
11 Correct 15 ms 28796 KB Output is correct
12 Correct 16 ms 28804 KB Output is correct
13 Correct 16 ms 28788 KB Output is correct
14 Correct 14 ms 28756 KB Output is correct
15 Correct 13 ms 28756 KB Output is correct
16 Correct 13 ms 28884 KB Output is correct
17 Correct 13 ms 28756 KB Output is correct
18 Correct 13 ms 28760 KB Output is correct
19 Correct 14 ms 28756 KB Output is correct
20 Correct 14 ms 28884 KB Output is correct
21 Correct 16 ms 28780 KB Output is correct
22 Correct 15 ms 28772 KB Output is correct
23 Correct 14 ms 28736 KB Output is correct
24 Correct 17 ms 28756 KB Output is correct
25 Correct 14 ms 27760 KB Output is correct
26 Correct 15 ms 27852 KB Output is correct
27 Correct 15 ms 28836 KB Output is correct
28 Correct 16 ms 28844 KB Output is correct
29 Correct 17 ms 28812 KB Output is correct
30 Correct 15 ms 28756 KB Output is correct
31 Correct 15 ms 28776 KB Output is correct
32 Correct 13 ms 28756 KB Output is correct
33 Correct 16 ms 28780 KB Output is correct
34 Correct 18 ms 28756 KB Output is correct
35 Correct 18 ms 28756 KB Output is correct
36 Correct 16 ms 28776 KB Output is correct
37 Correct 16 ms 28756 KB Output is correct
38 Correct 16 ms 28804 KB Output is correct
39 Correct 15 ms 28796 KB Output is correct
40 Correct 16 ms 28784 KB Output is correct
41 Correct 16 ms 28716 KB Output is correct
42 Correct 15 ms 28788 KB Output is correct
43 Correct 15 ms 28840 KB Output is correct
44 Correct 17 ms 28768 KB Output is correct
45 Correct 15 ms 28836 KB Output is correct
46 Correct 15 ms 28780 KB Output is correct
47 Correct 16 ms 28792 KB Output is correct
48 Correct 15 ms 28772 KB Output is correct
49 Correct 15 ms 28796 KB Output is correct
50 Correct 14 ms 28756 KB Output is correct
51 Correct 15 ms 28772 KB Output is correct
52 Correct 18 ms 28756 KB Output is correct
53 Correct 17 ms 28756 KB Output is correct
54 Correct 26 ms 28792 KB Output is correct
55 Correct 28 ms 28776 KB Output is correct
56 Correct 272 ms 28876 KB Output is correct
57 Correct 363 ms 32472 KB Output is correct
58 Execution timed out 2076 ms 25912 KB Time limit exceeded
59 Halted 0 ms 0 KB -