Submission #704527

# Submission time Handle Problem Language Result Execution time Memory
704527 2023-03-02T09:00:51 Z KenIsGenius Dango Maker (JOI18_dango_maker) C++17
33 / 100
246 ms 262144 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define ll long long
using namespace std;

#ifdef LOCAL
#define WOSAOJI freopen("in.txt", "r", stdin);
#else
#define WOSAOJI ios_base::sync_with_stdio(0), cin.tie(0);
#endif

#define chmax(a, b) (a) = (a) > (b) ? (a) : (b)
#define chmin(a, b) (a) = (a) < (b) ? (a) : (b)

int n, m, cnt;
char c[3005][3005];
int a[3005][3005];
vector<int> adj[9000005];

void add_edge(int a, int b) {
    adj[a].pb(b);
    adj[b].pb(a);
}
bool crow(int i, int j) {
    int ok = 1;
    ok &= (c[i][j - 2] == 'R');
    ok &= (c[i][j - 1] == 'G');
    ok &= (c[i][j    ] == 'W');
    return ok;
}
bool col(int i, int j) {
    int ok = 1;
    ok &= (c[i - 2][j] == 'R');
    ok &= (c[i - 1][j] == 'G');
    ok &= (c[i    ][j] == 'W');
    return ok;
}
int match[9000005];
void dfs(int x, int v) {
    match[x] = v;
    for (int i : adj[x]) {
        if (match[i] == v) {
            dfs(i, v ^ 1);
            return;
        }
    }
}
signed main() {
    WOSAOJI
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> c[i][j];
            if (j >= 3 and crow(i, j)) {
                cnt++;
                a[i][j] = a[i][j - 1] = a[i][j - 2] = cnt;
            }
        }
    }
    for (int i = 3; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (col(i, j)) {
                cnt++;
                if (a[i - 2][j])
                    add_edge(a[i - 2][j], cnt);
                if (a[i - 1][j])
                    add_edge(a[i - 1][j], cnt);
                if (a[i    ][j])
                    add_edge(a[i    ][j], cnt);
            }
        }
    }
    for (int i = 1; i <= cnt; i++) {
        if (!match[i]) dfs(i, 1);
    }
    int ans = 0;
    for (int i = 1; i <= cnt; i++) {
        ans += match[i];
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 97 ms 211676 KB Output is correct
2 Correct 95 ms 211636 KB Output is correct
3 Correct 93 ms 211624 KB Output is correct
4 Correct 97 ms 211660 KB Output is correct
5 Correct 98 ms 211644 KB Output is correct
6 Correct 98 ms 211600 KB Output is correct
7 Correct 97 ms 211616 KB Output is correct
8 Correct 102 ms 211616 KB Output is correct
9 Correct 94 ms 211660 KB Output is correct
10 Correct 98 ms 211660 KB Output is correct
11 Correct 103 ms 211576 KB Output is correct
12 Correct 97 ms 211688 KB Output is correct
13 Correct 107 ms 211596 KB Output is correct
14 Correct 95 ms 211648 KB Output is correct
15 Correct 96 ms 211684 KB Output is correct
16 Correct 96 ms 211692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 211676 KB Output is correct
2 Correct 95 ms 211636 KB Output is correct
3 Correct 93 ms 211624 KB Output is correct
4 Correct 97 ms 211660 KB Output is correct
5 Correct 98 ms 211644 KB Output is correct
6 Correct 98 ms 211600 KB Output is correct
7 Correct 97 ms 211616 KB Output is correct
8 Correct 102 ms 211616 KB Output is correct
9 Correct 94 ms 211660 KB Output is correct
10 Correct 98 ms 211660 KB Output is correct
11 Correct 103 ms 211576 KB Output is correct
12 Correct 97 ms 211688 KB Output is correct
13 Correct 107 ms 211596 KB Output is correct
14 Correct 95 ms 211648 KB Output is correct
15 Correct 96 ms 211684 KB Output is correct
16 Correct 96 ms 211692 KB Output is correct
17 Correct 95 ms 211668 KB Output is correct
18 Correct 97 ms 211692 KB Output is correct
19 Correct 95 ms 211636 KB Output is correct
20 Correct 95 ms 211708 KB Output is correct
21 Correct 97 ms 211660 KB Output is correct
22 Correct 95 ms 211708 KB Output is correct
23 Correct 99 ms 211640 KB Output is correct
24 Correct 95 ms 211656 KB Output is correct
25 Correct 100 ms 211748 KB Output is correct
26 Correct 96 ms 211572 KB Output is correct
27 Correct 95 ms 211704 KB Output is correct
28 Correct 96 ms 211660 KB Output is correct
29 Correct 96 ms 211732 KB Output is correct
30 Correct 103 ms 211716 KB Output is correct
31 Correct 96 ms 211660 KB Output is correct
32 Correct 100 ms 211608 KB Output is correct
33 Correct 95 ms 211620 KB Output is correct
34 Correct 95 ms 211720 KB Output is correct
35 Correct 101 ms 211680 KB Output is correct
36 Correct 95 ms 211660 KB Output is correct
37 Correct 95 ms 211672 KB Output is correct
38 Correct 99 ms 211728 KB Output is correct
39 Correct 94 ms 211732 KB Output is correct
40 Correct 97 ms 211760 KB Output is correct
41 Correct 96 ms 211652 KB Output is correct
42 Correct 102 ms 211736 KB Output is correct
43 Correct 104 ms 211616 KB Output is correct
44 Correct 95 ms 211676 KB Output is correct
45 Correct 96 ms 211684 KB Output is correct
46 Correct 97 ms 211660 KB Output is correct
47 Correct 107 ms 211620 KB Output is correct
48 Correct 97 ms 211740 KB Output is correct
49 Correct 101 ms 211684 KB Output is correct
50 Correct 95 ms 211652 KB Output is correct
51 Correct 96 ms 211776 KB Output is correct
52 Correct 96 ms 211660 KB Output is correct
53 Correct 95 ms 211656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 211676 KB Output is correct
2 Correct 95 ms 211636 KB Output is correct
3 Correct 93 ms 211624 KB Output is correct
4 Correct 97 ms 211660 KB Output is correct
5 Correct 98 ms 211644 KB Output is correct
6 Correct 98 ms 211600 KB Output is correct
7 Correct 97 ms 211616 KB Output is correct
8 Correct 102 ms 211616 KB Output is correct
9 Correct 94 ms 211660 KB Output is correct
10 Correct 98 ms 211660 KB Output is correct
11 Correct 103 ms 211576 KB Output is correct
12 Correct 97 ms 211688 KB Output is correct
13 Correct 107 ms 211596 KB Output is correct
14 Correct 95 ms 211648 KB Output is correct
15 Correct 96 ms 211684 KB Output is correct
16 Correct 96 ms 211692 KB Output is correct
17 Correct 95 ms 211668 KB Output is correct
18 Correct 97 ms 211692 KB Output is correct
19 Correct 95 ms 211636 KB Output is correct
20 Correct 95 ms 211708 KB Output is correct
21 Correct 97 ms 211660 KB Output is correct
22 Correct 95 ms 211708 KB Output is correct
23 Correct 99 ms 211640 KB Output is correct
24 Correct 95 ms 211656 KB Output is correct
25 Correct 100 ms 211748 KB Output is correct
26 Correct 96 ms 211572 KB Output is correct
27 Correct 95 ms 211704 KB Output is correct
28 Correct 96 ms 211660 KB Output is correct
29 Correct 96 ms 211732 KB Output is correct
30 Correct 103 ms 211716 KB Output is correct
31 Correct 96 ms 211660 KB Output is correct
32 Correct 100 ms 211608 KB Output is correct
33 Correct 95 ms 211620 KB Output is correct
34 Correct 95 ms 211720 KB Output is correct
35 Correct 101 ms 211680 KB Output is correct
36 Correct 95 ms 211660 KB Output is correct
37 Correct 95 ms 211672 KB Output is correct
38 Correct 99 ms 211728 KB Output is correct
39 Correct 94 ms 211732 KB Output is correct
40 Correct 97 ms 211760 KB Output is correct
41 Correct 96 ms 211652 KB Output is correct
42 Correct 102 ms 211736 KB Output is correct
43 Correct 104 ms 211616 KB Output is correct
44 Correct 95 ms 211676 KB Output is correct
45 Correct 96 ms 211684 KB Output is correct
46 Correct 97 ms 211660 KB Output is correct
47 Correct 107 ms 211620 KB Output is correct
48 Correct 97 ms 211740 KB Output is correct
49 Correct 101 ms 211684 KB Output is correct
50 Correct 95 ms 211652 KB Output is correct
51 Correct 96 ms 211776 KB Output is correct
52 Correct 96 ms 211660 KB Output is correct
53 Correct 95 ms 211656 KB Output is correct
54 Correct 94 ms 211624 KB Output is correct
55 Correct 112 ms 220556 KB Output is correct
56 Correct 99 ms 211764 KB Output is correct
57 Correct 101 ms 222536 KB Output is correct
58 Correct 115 ms 223556 KB Output is correct
59 Runtime error 246 ms 262144 KB Execution killed with signal 9
60 Halted 0 ms 0 KB -