#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';
}
Compilation message
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:67:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
67 | if (a[i - 2][j]) ;
| ^~
dango_maker.cpp:68:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
68 | add_edge(a[i - 2][j], cnt);
| ^~~~~~~~
dango_maker.cpp:69:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
69 | if (a[i - 1][j]) ;
| ^~
dango_maker.cpp:70:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
70 | add_edge(a[i - 1][j], cnt);
| ^~~~~~~~
dango_maker.cpp:71:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
71 | if (a[i ][j]) ;
| ^~
dango_maker.cpp:72:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
72 | add_edge(a[i ][j], cnt);
| ^~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
211604 KB |
Output is correct |
2 |
Correct |
95 ms |
211672 KB |
Output is correct |
3 |
Correct |
94 ms |
211624 KB |
Output is correct |
4 |
Correct |
96 ms |
211864 KB |
Output is correct |
5 |
Correct |
99 ms |
211568 KB |
Output is correct |
6 |
Correct |
95 ms |
211576 KB |
Output is correct |
7 |
Correct |
101 ms |
211660 KB |
Output is correct |
8 |
Correct |
97 ms |
211660 KB |
Output is correct |
9 |
Correct |
99 ms |
211748 KB |
Output is correct |
10 |
Correct |
97 ms |
211584 KB |
Output is correct |
11 |
Correct |
95 ms |
211660 KB |
Output is correct |
12 |
Correct |
96 ms |
211668 KB |
Output is correct |
13 |
Correct |
95 ms |
211604 KB |
Output is correct |
14 |
Correct |
96 ms |
211596 KB |
Output is correct |
15 |
Correct |
94 ms |
211660 KB |
Output is correct |
16 |
Correct |
96 ms |
211596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
211604 KB |
Output is correct |
2 |
Correct |
95 ms |
211672 KB |
Output is correct |
3 |
Correct |
94 ms |
211624 KB |
Output is correct |
4 |
Correct |
96 ms |
211864 KB |
Output is correct |
5 |
Correct |
99 ms |
211568 KB |
Output is correct |
6 |
Correct |
95 ms |
211576 KB |
Output is correct |
7 |
Correct |
101 ms |
211660 KB |
Output is correct |
8 |
Correct |
97 ms |
211660 KB |
Output is correct |
9 |
Correct |
99 ms |
211748 KB |
Output is correct |
10 |
Correct |
97 ms |
211584 KB |
Output is correct |
11 |
Correct |
95 ms |
211660 KB |
Output is correct |
12 |
Correct |
96 ms |
211668 KB |
Output is correct |
13 |
Correct |
95 ms |
211604 KB |
Output is correct |
14 |
Correct |
96 ms |
211596 KB |
Output is correct |
15 |
Correct |
94 ms |
211660 KB |
Output is correct |
16 |
Correct |
96 ms |
211596 KB |
Output is correct |
17 |
Correct |
96 ms |
211592 KB |
Output is correct |
18 |
Correct |
96 ms |
211696 KB |
Output is correct |
19 |
Correct |
100 ms |
211812 KB |
Output is correct |
20 |
Correct |
95 ms |
211712 KB |
Output is correct |
21 |
Correct |
94 ms |
211684 KB |
Output is correct |
22 |
Correct |
105 ms |
211648 KB |
Output is correct |
23 |
Correct |
96 ms |
211664 KB |
Output is correct |
24 |
Correct |
95 ms |
211664 KB |
Output is correct |
25 |
Correct |
96 ms |
211688 KB |
Output is correct |
26 |
Correct |
95 ms |
211652 KB |
Output is correct |
27 |
Correct |
95 ms |
211672 KB |
Output is correct |
28 |
Correct |
94 ms |
211664 KB |
Output is correct |
29 |
Correct |
99 ms |
211788 KB |
Output is correct |
30 |
Correct |
97 ms |
211608 KB |
Output is correct |
31 |
Correct |
97 ms |
211632 KB |
Output is correct |
32 |
Correct |
94 ms |
211600 KB |
Output is correct |
33 |
Correct |
95 ms |
211744 KB |
Output is correct |
34 |
Correct |
95 ms |
211620 KB |
Output is correct |
35 |
Correct |
96 ms |
211668 KB |
Output is correct |
36 |
Correct |
97 ms |
211680 KB |
Output is correct |
37 |
Correct |
94 ms |
211736 KB |
Output is correct |
38 |
Correct |
95 ms |
211680 KB |
Output is correct |
39 |
Correct |
97 ms |
211696 KB |
Output is correct |
40 |
Correct |
94 ms |
211736 KB |
Output is correct |
41 |
Correct |
94 ms |
211652 KB |
Output is correct |
42 |
Correct |
95 ms |
211724 KB |
Output is correct |
43 |
Correct |
101 ms |
211680 KB |
Output is correct |
44 |
Correct |
101 ms |
211872 KB |
Output is correct |
45 |
Correct |
96 ms |
211676 KB |
Output is correct |
46 |
Correct |
94 ms |
211660 KB |
Output is correct |
47 |
Correct |
93 ms |
211728 KB |
Output is correct |
48 |
Correct |
92 ms |
211660 KB |
Output is correct |
49 |
Correct |
95 ms |
211832 KB |
Output is correct |
50 |
Correct |
95 ms |
211648 KB |
Output is correct |
51 |
Correct |
99 ms |
211680 KB |
Output is correct |
52 |
Correct |
94 ms |
211620 KB |
Output is correct |
53 |
Correct |
96 ms |
211716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
211604 KB |
Output is correct |
2 |
Correct |
95 ms |
211672 KB |
Output is correct |
3 |
Correct |
94 ms |
211624 KB |
Output is correct |
4 |
Correct |
96 ms |
211864 KB |
Output is correct |
5 |
Correct |
99 ms |
211568 KB |
Output is correct |
6 |
Correct |
95 ms |
211576 KB |
Output is correct |
7 |
Correct |
101 ms |
211660 KB |
Output is correct |
8 |
Correct |
97 ms |
211660 KB |
Output is correct |
9 |
Correct |
99 ms |
211748 KB |
Output is correct |
10 |
Correct |
97 ms |
211584 KB |
Output is correct |
11 |
Correct |
95 ms |
211660 KB |
Output is correct |
12 |
Correct |
96 ms |
211668 KB |
Output is correct |
13 |
Correct |
95 ms |
211604 KB |
Output is correct |
14 |
Correct |
96 ms |
211596 KB |
Output is correct |
15 |
Correct |
94 ms |
211660 KB |
Output is correct |
16 |
Correct |
96 ms |
211596 KB |
Output is correct |
17 |
Correct |
96 ms |
211592 KB |
Output is correct |
18 |
Correct |
96 ms |
211696 KB |
Output is correct |
19 |
Correct |
100 ms |
211812 KB |
Output is correct |
20 |
Correct |
95 ms |
211712 KB |
Output is correct |
21 |
Correct |
94 ms |
211684 KB |
Output is correct |
22 |
Correct |
105 ms |
211648 KB |
Output is correct |
23 |
Correct |
96 ms |
211664 KB |
Output is correct |
24 |
Correct |
95 ms |
211664 KB |
Output is correct |
25 |
Correct |
96 ms |
211688 KB |
Output is correct |
26 |
Correct |
95 ms |
211652 KB |
Output is correct |
27 |
Correct |
95 ms |
211672 KB |
Output is correct |
28 |
Correct |
94 ms |
211664 KB |
Output is correct |
29 |
Correct |
99 ms |
211788 KB |
Output is correct |
30 |
Correct |
97 ms |
211608 KB |
Output is correct |
31 |
Correct |
97 ms |
211632 KB |
Output is correct |
32 |
Correct |
94 ms |
211600 KB |
Output is correct |
33 |
Correct |
95 ms |
211744 KB |
Output is correct |
34 |
Correct |
95 ms |
211620 KB |
Output is correct |
35 |
Correct |
96 ms |
211668 KB |
Output is correct |
36 |
Correct |
97 ms |
211680 KB |
Output is correct |
37 |
Correct |
94 ms |
211736 KB |
Output is correct |
38 |
Correct |
95 ms |
211680 KB |
Output is correct |
39 |
Correct |
97 ms |
211696 KB |
Output is correct |
40 |
Correct |
94 ms |
211736 KB |
Output is correct |
41 |
Correct |
94 ms |
211652 KB |
Output is correct |
42 |
Correct |
95 ms |
211724 KB |
Output is correct |
43 |
Correct |
101 ms |
211680 KB |
Output is correct |
44 |
Correct |
101 ms |
211872 KB |
Output is correct |
45 |
Correct |
96 ms |
211676 KB |
Output is correct |
46 |
Correct |
94 ms |
211660 KB |
Output is correct |
47 |
Correct |
93 ms |
211728 KB |
Output is correct |
48 |
Correct |
92 ms |
211660 KB |
Output is correct |
49 |
Correct |
95 ms |
211832 KB |
Output is correct |
50 |
Correct |
95 ms |
211648 KB |
Output is correct |
51 |
Correct |
99 ms |
211680 KB |
Output is correct |
52 |
Correct |
94 ms |
211620 KB |
Output is correct |
53 |
Correct |
96 ms |
211716 KB |
Output is correct |
54 |
Correct |
95 ms |
211656 KB |
Output is correct |
55 |
Correct |
98 ms |
220520 KB |
Output is correct |
56 |
Correct |
94 ms |
211836 KB |
Output is correct |
57 |
Correct |
98 ms |
222568 KB |
Output is correct |
58 |
Correct |
122 ms |
224868 KB |
Output is correct |
59 |
Runtime error |
239 ms |
262144 KB |
Execution killed with signal 9 |
60 |
Halted |
0 ms |
0 KB |
- |