Submission #303894

# Submission time Handle Problem Language Result Execution time Memory
303894 2020-09-20T18:04:00 Z pit4h Dango Maker (JOI18_dango_maker) C++14
33 / 100
256 ms 262148 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 3001;
int n, m, nr;
int matched[N * N], vis[N * N], rep[N][N];
int iter;
bool horiz[N][N], vert[N][N];
string tab[N];
vector<int> g[N * N];
bool match(int x) {
	vis[x] = iter;
	for(int i: g[x]) {
		if(matched[i] == -1) {
			matched[i] = x;
			return true;
		}
	}
	for(int i: g[x]) {
		if(vis[matched[i]] != iter && match(matched[i])) {
			matched[i] = x;
			return true;
		}
	}
	return false;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	for(int i=n-1; i>=0; --i) {
		cin>>tab[i];
	}
	for(int i=0; i<n; ++i) { // left - right
		for(int j=0; j+2<m; ++j) {
			if(tab[i][j] == 'R' && tab[i][j+1] == 'G' && tab[i][j+2] == 'W') {
				vert[i][j] = 1;
			}
		}
	}
	for(int i=2; i<n; ++i) { // top - bottom 
		for(int j=0; j<m; ++j) {
			if(tab[i][j] == 'R' && tab[i-1][j] == 'G' && tab[i-2][j] == 'W') {
				horiz[i][j] = 1;
				rep[i][j] = nr;
				nr++;
			}
		}
	}
	int sz = 0;
	for(int i=0; i<n; ++i) {
		for(int j=0; j<m; ++j) {
			if(vert[i][j]) {
				if(horiz[i][j]) {
					g[sz].push_back(rep[i][j]);
				}
				if(i+1<n && j+1<m && horiz[i+1][j+1]) {
					g[sz].push_back(rep[i+1][j+1]);
				}
				if(i+2<n && j+2<m && horiz[i+2][j+2]) {
					g[sz].push_back(rep[i+2][j+2]);
				}
				sz++;
			}
		}
	}
	for(int i=0; i<nr; ++i) {
		matched[i] = -1;
	}
	int ans = 0;
	for(int i=0; i<sz; ++i) {
		iter++;
		match(i);
	}
	for(int i=0; i<nr; ++i) {
		if(matched[i] != -1) {
			ans++;
		}
	}
	cout<<nr + sz - ans;
}
# Verdict Execution time Memory Grader output
1 Correct 130 ms 211960 KB Output is correct
2 Correct 130 ms 211960 KB Output is correct
3 Correct 132 ms 211960 KB Output is correct
4 Correct 135 ms 211960 KB Output is correct
5 Correct 130 ms 211960 KB Output is correct
6 Correct 141 ms 211960 KB Output is correct
7 Correct 131 ms 211892 KB Output is correct
8 Correct 130 ms 211968 KB Output is correct
9 Correct 130 ms 211960 KB Output is correct
10 Correct 131 ms 211960 KB Output is correct
11 Correct 130 ms 211960 KB Output is correct
12 Correct 131 ms 212088 KB Output is correct
13 Correct 130 ms 212088 KB Output is correct
14 Correct 133 ms 211988 KB Output is correct
15 Correct 131 ms 211960 KB Output is correct
16 Correct 129 ms 211992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 211960 KB Output is correct
2 Correct 130 ms 211960 KB Output is correct
3 Correct 132 ms 211960 KB Output is correct
4 Correct 135 ms 211960 KB Output is correct
5 Correct 130 ms 211960 KB Output is correct
6 Correct 141 ms 211960 KB Output is correct
7 Correct 131 ms 211892 KB Output is correct
8 Correct 130 ms 211968 KB Output is correct
9 Correct 130 ms 211960 KB Output is correct
10 Correct 131 ms 211960 KB Output is correct
11 Correct 130 ms 211960 KB Output is correct
12 Correct 131 ms 212088 KB Output is correct
13 Correct 130 ms 212088 KB Output is correct
14 Correct 133 ms 211988 KB Output is correct
15 Correct 131 ms 211960 KB Output is correct
16 Correct 129 ms 211992 KB Output is correct
17 Correct 133 ms 212180 KB Output is correct
18 Correct 136 ms 211960 KB Output is correct
19 Correct 130 ms 211964 KB Output is correct
20 Correct 129 ms 211964 KB Output is correct
21 Correct 132 ms 211992 KB Output is correct
22 Correct 131 ms 212056 KB Output is correct
23 Correct 133 ms 212024 KB Output is correct
24 Correct 130 ms 211960 KB Output is correct
25 Correct 132 ms 211940 KB Output is correct
26 Correct 134 ms 211960 KB Output is correct
27 Correct 133 ms 212084 KB Output is correct
28 Correct 134 ms 212088 KB Output is correct
29 Correct 130 ms 211960 KB Output is correct
30 Correct 128 ms 211964 KB Output is correct
31 Correct 140 ms 211960 KB Output is correct
32 Correct 130 ms 211960 KB Output is correct
33 Correct 130 ms 212088 KB Output is correct
34 Correct 130 ms 211960 KB Output is correct
35 Correct 130 ms 211964 KB Output is correct
36 Correct 130 ms 212088 KB Output is correct
37 Correct 132 ms 211960 KB Output is correct
38 Correct 132 ms 212068 KB Output is correct
39 Correct 130 ms 211960 KB Output is correct
40 Correct 129 ms 211960 KB Output is correct
41 Correct 133 ms 211960 KB Output is correct
42 Correct 130 ms 212088 KB Output is correct
43 Correct 129 ms 212088 KB Output is correct
44 Correct 133 ms 211960 KB Output is correct
45 Correct 132 ms 211960 KB Output is correct
46 Correct 133 ms 212092 KB Output is correct
47 Correct 129 ms 211960 KB Output is correct
48 Correct 133 ms 211960 KB Output is correct
49 Correct 131 ms 211960 KB Output is correct
50 Correct 132 ms 211960 KB Output is correct
51 Correct 131 ms 211960 KB Output is correct
52 Correct 129 ms 211964 KB Output is correct
53 Correct 128 ms 211960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 211960 KB Output is correct
2 Correct 130 ms 211960 KB Output is correct
3 Correct 132 ms 211960 KB Output is correct
4 Correct 135 ms 211960 KB Output is correct
5 Correct 130 ms 211960 KB Output is correct
6 Correct 141 ms 211960 KB Output is correct
7 Correct 131 ms 211892 KB Output is correct
8 Correct 130 ms 211968 KB Output is correct
9 Correct 130 ms 211960 KB Output is correct
10 Correct 131 ms 211960 KB Output is correct
11 Correct 130 ms 211960 KB Output is correct
12 Correct 131 ms 212088 KB Output is correct
13 Correct 130 ms 212088 KB Output is correct
14 Correct 133 ms 211988 KB Output is correct
15 Correct 131 ms 211960 KB Output is correct
16 Correct 129 ms 211992 KB Output is correct
17 Correct 133 ms 212180 KB Output is correct
18 Correct 136 ms 211960 KB Output is correct
19 Correct 130 ms 211964 KB Output is correct
20 Correct 129 ms 211964 KB Output is correct
21 Correct 132 ms 211992 KB Output is correct
22 Correct 131 ms 212056 KB Output is correct
23 Correct 133 ms 212024 KB Output is correct
24 Correct 130 ms 211960 KB Output is correct
25 Correct 132 ms 211940 KB Output is correct
26 Correct 134 ms 211960 KB Output is correct
27 Correct 133 ms 212084 KB Output is correct
28 Correct 134 ms 212088 KB Output is correct
29 Correct 130 ms 211960 KB Output is correct
30 Correct 128 ms 211964 KB Output is correct
31 Correct 140 ms 211960 KB Output is correct
32 Correct 130 ms 211960 KB Output is correct
33 Correct 130 ms 212088 KB Output is correct
34 Correct 130 ms 211960 KB Output is correct
35 Correct 130 ms 211964 KB Output is correct
36 Correct 130 ms 212088 KB Output is correct
37 Correct 132 ms 211960 KB Output is correct
38 Correct 132 ms 212068 KB Output is correct
39 Correct 130 ms 211960 KB Output is correct
40 Correct 129 ms 211960 KB Output is correct
41 Correct 133 ms 211960 KB Output is correct
42 Correct 130 ms 212088 KB Output is correct
43 Correct 129 ms 212088 KB Output is correct
44 Correct 133 ms 211960 KB Output is correct
45 Correct 132 ms 211960 KB Output is correct
46 Correct 133 ms 212092 KB Output is correct
47 Correct 129 ms 211960 KB Output is correct
48 Correct 133 ms 211960 KB Output is correct
49 Correct 131 ms 211960 KB Output is correct
50 Correct 132 ms 211960 KB Output is correct
51 Correct 131 ms 211960 KB Output is correct
52 Correct 129 ms 211964 KB Output is correct
53 Correct 128 ms 211960 KB Output is correct
54 Correct 130 ms 211960 KB Output is correct
55 Correct 134 ms 212856 KB Output is correct
56 Correct 132 ms 212068 KB Output is correct
57 Correct 138 ms 225144 KB Output is correct
58 Correct 157 ms 228344 KB Output is correct
59 Runtime error 256 ms 262148 KB Execution killed with signal 9
60 Halted 0 ms 0 KB -