#include <bits/stdc++.h>
using namespace std;
vector<int> vis, match;
vector<int> adj[200000];
int Aug(int u){
if(vis[u]) return 0;
vis[u] = 1;
for(int j = 0;j < adj[u].size();j++){
int r = adj[u][j];
if(match[r] == -1 || Aug(match[r])){
match[r] = u;
return 1;
}
}
return 0;
}
int main()
{
//freopen("i.txt","r",stdin);
ios_base::sync_with_stdio(false);
cin.tie(0);
int rows, cols;
cin >> rows >> cols;
int arr[rows][cols];
for(int r = 0;r < rows;r++){
string s;
cin >> s;
for(int c = 0;c < cols;c++){
if(s[c] == 'R') arr[r][c] = 0;
else if(s[c] == 'G') arr[r][c] = 1;
else arr[r][c] = 2;
}
}
typedef pair<int,int> ii;
vector<ii> ver;
vector<ii> hor;
for(int r = 0;r < rows;r++){
for(int c = 0;c < cols - 2;c++){
if(arr[r][c] == 0 && arr[r][c+1] == 1 && arr[r][c+2] == 2){
hor.push_back(ii(r,c));
}
}
}
for(int r = 0;r < rows - 2;r++){
for(int c = 0;c < cols;c++){
if(arr[r][c] == 0 && arr[r+1][c] == 1 && arr[r+2][c] == 2){
ver.push_back(ii(r,c));
}
}
}
int n = ver.size();
int m = hor.size();
int V = n + m;
//cout << ver[0].first << " " << ver[0].second << "\n";
//cout << hor[1].first << " " << hor[1].second << "\n";
for(int i = 0;i < n;i++){
for(int j = 0;j < m;j++){
set<ii> nodes;
ii x = hor[j];
nodes.insert(x);
x.second++;
nodes.insert(x);
x.second++;
nodes.insert(x);
x.second++;
ii y = ver[i];
nodes.insert(y);
y.first++;
nodes.insert(y);
y.first++;
nodes.insert(y);
y.first++;
if(nodes.size() != 6){
adj[i].push_back(j+n);
//cout << i << " " << j << "\n";
}
}
}
int MCBM = 0;
match.assign(V,-1);
for(int i = 0;i < n;i++){
vis.assign(n,0);
MCBM += Aug(i);
}
cout << V - MCBM;
return 0;
}
Compilation message
dango_maker.cpp: In function 'int Aug(int)':
dango_maker.cpp:10:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j = 0;j < adj[u].size();j++){
~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
5120 KB |
Output is correct |
2 |
Correct |
5 ms |
4992 KB |
Output is correct |
3 |
Correct |
6 ms |
4992 KB |
Output is correct |
4 |
Correct |
6 ms |
5120 KB |
Output is correct |
5 |
Correct |
6 ms |
4992 KB |
Output is correct |
6 |
Correct |
6 ms |
4992 KB |
Output is correct |
7 |
Correct |
6 ms |
5120 KB |
Output is correct |
8 |
Correct |
5 ms |
4992 KB |
Output is correct |
9 |
Correct |
6 ms |
5120 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
5 ms |
4992 KB |
Output is correct |
12 |
Correct |
6 ms |
4992 KB |
Output is correct |
13 |
Correct |
7 ms |
5128 KB |
Output is correct |
14 |
Correct |
6 ms |
4992 KB |
Output is correct |
15 |
Correct |
6 ms |
4992 KB |
Output is correct |
16 |
Correct |
6 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
5120 KB |
Output is correct |
2 |
Correct |
5 ms |
4992 KB |
Output is correct |
3 |
Correct |
6 ms |
4992 KB |
Output is correct |
4 |
Correct |
6 ms |
5120 KB |
Output is correct |
5 |
Correct |
6 ms |
4992 KB |
Output is correct |
6 |
Correct |
6 ms |
4992 KB |
Output is correct |
7 |
Correct |
6 ms |
5120 KB |
Output is correct |
8 |
Correct |
5 ms |
4992 KB |
Output is correct |
9 |
Correct |
6 ms |
5120 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
5 ms |
4992 KB |
Output is correct |
12 |
Correct |
6 ms |
4992 KB |
Output is correct |
13 |
Correct |
7 ms |
5128 KB |
Output is correct |
14 |
Correct |
6 ms |
4992 KB |
Output is correct |
15 |
Correct |
6 ms |
4992 KB |
Output is correct |
16 |
Correct |
6 ms |
5120 KB |
Output is correct |
17 |
Correct |
6 ms |
4992 KB |
Output is correct |
18 |
Correct |
5 ms |
4992 KB |
Output is correct |
19 |
Correct |
5 ms |
4992 KB |
Output is correct |
20 |
Correct |
7 ms |
5120 KB |
Output is correct |
21 |
Correct |
6 ms |
4992 KB |
Output is correct |
22 |
Correct |
6 ms |
5120 KB |
Output is correct |
23 |
Correct |
6 ms |
4992 KB |
Output is correct |
24 |
Correct |
6 ms |
4992 KB |
Output is correct |
25 |
Correct |
6 ms |
5120 KB |
Output is correct |
26 |
Correct |
6 ms |
4992 KB |
Output is correct |
27 |
Correct |
7 ms |
5092 KB |
Output is correct |
28 |
Correct |
6 ms |
4992 KB |
Output is correct |
29 |
Correct |
6 ms |
4992 KB |
Output is correct |
30 |
Correct |
6 ms |
4992 KB |
Output is correct |
31 |
Correct |
6 ms |
5120 KB |
Output is correct |
32 |
Correct |
6 ms |
4992 KB |
Output is correct |
33 |
Correct |
6 ms |
4992 KB |
Output is correct |
34 |
Correct |
7 ms |
4992 KB |
Output is correct |
35 |
Correct |
7 ms |
4992 KB |
Output is correct |
36 |
Correct |
7 ms |
4992 KB |
Output is correct |
37 |
Correct |
7 ms |
5120 KB |
Output is correct |
38 |
Correct |
6 ms |
4992 KB |
Output is correct |
39 |
Correct |
7 ms |
4992 KB |
Output is correct |
40 |
Correct |
6 ms |
5120 KB |
Output is correct |
41 |
Correct |
7 ms |
4992 KB |
Output is correct |
42 |
Correct |
6 ms |
5120 KB |
Output is correct |
43 |
Correct |
6 ms |
5120 KB |
Output is correct |
44 |
Correct |
6 ms |
5120 KB |
Output is correct |
45 |
Correct |
6 ms |
5120 KB |
Output is correct |
46 |
Correct |
6 ms |
5120 KB |
Output is correct |
47 |
Correct |
6 ms |
5120 KB |
Output is correct |
48 |
Correct |
7 ms |
5120 KB |
Output is correct |
49 |
Correct |
6 ms |
5120 KB |
Output is correct |
50 |
Correct |
7 ms |
5120 KB |
Output is correct |
51 |
Correct |
6 ms |
5120 KB |
Output is correct |
52 |
Correct |
6 ms |
4992 KB |
Output is correct |
53 |
Correct |
6 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
5120 KB |
Output is correct |
2 |
Correct |
5 ms |
4992 KB |
Output is correct |
3 |
Correct |
6 ms |
4992 KB |
Output is correct |
4 |
Correct |
6 ms |
5120 KB |
Output is correct |
5 |
Correct |
6 ms |
4992 KB |
Output is correct |
6 |
Correct |
6 ms |
4992 KB |
Output is correct |
7 |
Correct |
6 ms |
5120 KB |
Output is correct |
8 |
Correct |
5 ms |
4992 KB |
Output is correct |
9 |
Correct |
6 ms |
5120 KB |
Output is correct |
10 |
Correct |
7 ms |
4992 KB |
Output is correct |
11 |
Correct |
5 ms |
4992 KB |
Output is correct |
12 |
Correct |
6 ms |
4992 KB |
Output is correct |
13 |
Correct |
7 ms |
5128 KB |
Output is correct |
14 |
Correct |
6 ms |
4992 KB |
Output is correct |
15 |
Correct |
6 ms |
4992 KB |
Output is correct |
16 |
Correct |
6 ms |
5120 KB |
Output is correct |
17 |
Correct |
6 ms |
4992 KB |
Output is correct |
18 |
Correct |
5 ms |
4992 KB |
Output is correct |
19 |
Correct |
5 ms |
4992 KB |
Output is correct |
20 |
Correct |
7 ms |
5120 KB |
Output is correct |
21 |
Correct |
6 ms |
4992 KB |
Output is correct |
22 |
Correct |
6 ms |
5120 KB |
Output is correct |
23 |
Correct |
6 ms |
4992 KB |
Output is correct |
24 |
Correct |
6 ms |
4992 KB |
Output is correct |
25 |
Correct |
6 ms |
5120 KB |
Output is correct |
26 |
Correct |
6 ms |
4992 KB |
Output is correct |
27 |
Correct |
7 ms |
5092 KB |
Output is correct |
28 |
Correct |
6 ms |
4992 KB |
Output is correct |
29 |
Correct |
6 ms |
4992 KB |
Output is correct |
30 |
Correct |
6 ms |
4992 KB |
Output is correct |
31 |
Correct |
6 ms |
5120 KB |
Output is correct |
32 |
Correct |
6 ms |
4992 KB |
Output is correct |
33 |
Correct |
6 ms |
4992 KB |
Output is correct |
34 |
Correct |
7 ms |
4992 KB |
Output is correct |
35 |
Correct |
7 ms |
4992 KB |
Output is correct |
36 |
Correct |
7 ms |
4992 KB |
Output is correct |
37 |
Correct |
7 ms |
5120 KB |
Output is correct |
38 |
Correct |
6 ms |
4992 KB |
Output is correct |
39 |
Correct |
7 ms |
4992 KB |
Output is correct |
40 |
Correct |
6 ms |
5120 KB |
Output is correct |
41 |
Correct |
7 ms |
4992 KB |
Output is correct |
42 |
Correct |
6 ms |
5120 KB |
Output is correct |
43 |
Correct |
6 ms |
5120 KB |
Output is correct |
44 |
Correct |
6 ms |
5120 KB |
Output is correct |
45 |
Correct |
6 ms |
5120 KB |
Output is correct |
46 |
Correct |
6 ms |
5120 KB |
Output is correct |
47 |
Correct |
6 ms |
5120 KB |
Output is correct |
48 |
Correct |
7 ms |
5120 KB |
Output is correct |
49 |
Correct |
6 ms |
5120 KB |
Output is correct |
50 |
Correct |
7 ms |
5120 KB |
Output is correct |
51 |
Correct |
6 ms |
5120 KB |
Output is correct |
52 |
Correct |
6 ms |
4992 KB |
Output is correct |
53 |
Correct |
6 ms |
5120 KB |
Output is correct |
54 |
Correct |
5 ms |
4992 KB |
Output is correct |
55 |
Correct |
6 ms |
4992 KB |
Output is correct |
56 |
Correct |
560 ms |
5196 KB |
Output is correct |
57 |
Correct |
696 ms |
5240 KB |
Output is correct |
58 |
Execution timed out |
2060 ms |
11124 KB |
Time limit exceeded |
59 |
Halted |
0 ms |
0 KB |
- |