답안 #86850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
86850 2018-11-27T20:22:59 Z KCSC Dango Maker (JOI18_dango_maker) C++14
33 / 100
539 ms 263168 KB
#include <bits/stdc++.h>
using namespace std;

const int DIM = 3109;
const int di[9] = {-2, -2, -2, -1, -1, -1, 0, 0, 0};
const int dj[9] = {0, 1, 2, 0, 1, 2, 0, 1, 2};

char str[DIM][DIM];
int val1[DIM][DIM], val2[DIM][DIM]; 
int lef[DIM * DIM], rig[DIM * DIM];

bitset<DIM * DIM> mrk;
vector<int> edg[DIM * DIM];

bool match(int x, int &ans) {
	if (mrk[x]) {
		return false; }
	mrk[x] = true;
	for (int y : edg[x]) { if (!rig[y]) {
		lef[x] = y; rig[y] = x; --ans; return true; } }
	for (int y : edg[x]) { if (match(rig[y], ans)) {
		lef[x] = y; rig[y] = x; return true; } }
	return false; }

int main(void) {
#ifdef HOME
	freopen("dango.in", "r", stdin);
	freopen("dango.out", "w", stdout);
#endif
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> (str[i] + 1); }
	int nr1 = 0, nr2 = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (j + 2 <= m and str[i][j] == 'R' and str[i][j + 1] == 'G' and str[i][j + 2] == 'W') {
				val1[i][j] = ++nr1; }
			if (i + 2 <= n and str[i][j] == 'R' and str[i + 1][j] == 'G' and str[i + 2][j] == 'W') {
				val2[i][j] = ++nr2; } } }
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (!val1[i][j]) {
				continue; }
			for (int d = 0; d < 9; ++d) {
				int ii = i + di[d], jj = j + dj[d];
				if (ii >= 1 and jj <= m and val2[ii][jj]) {
					edg[val1[i][j]].push_back(val2[ii][jj]); } } } }
	bool ok; int ans = nr1 + nr2; do {
		ok = false; mrk.reset();
		for (int i = 1; i <= nr1; ++i) {
			if (!lef[i] and match(i, ans)) {
				ok = true; } }
	} while (ok);
	cout << ans;
	return 0; }
# 결과 실행 시간 메모리 Grader output
1 Correct 207 ms 228472 KB Output is correct
2 Correct 207 ms 228600 KB Output is correct
3 Correct 214 ms 228708 KB Output is correct
4 Correct 209 ms 228708 KB Output is correct
5 Correct 209 ms 228708 KB Output is correct
6 Correct 215 ms 228732 KB Output is correct
7 Correct 206 ms 228732 KB Output is correct
8 Correct 208 ms 228800 KB Output is correct
9 Correct 208 ms 228804 KB Output is correct
10 Correct 213 ms 228852 KB Output is correct
11 Correct 207 ms 228944 KB Output is correct
12 Correct 205 ms 228944 KB Output is correct
13 Correct 207 ms 228944 KB Output is correct
14 Correct 207 ms 228944 KB Output is correct
15 Correct 205 ms 228944 KB Output is correct
16 Correct 199 ms 228944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 207 ms 228472 KB Output is correct
2 Correct 207 ms 228600 KB Output is correct
3 Correct 214 ms 228708 KB Output is correct
4 Correct 209 ms 228708 KB Output is correct
5 Correct 209 ms 228708 KB Output is correct
6 Correct 215 ms 228732 KB Output is correct
7 Correct 206 ms 228732 KB Output is correct
8 Correct 208 ms 228800 KB Output is correct
9 Correct 208 ms 228804 KB Output is correct
10 Correct 213 ms 228852 KB Output is correct
11 Correct 207 ms 228944 KB Output is correct
12 Correct 205 ms 228944 KB Output is correct
13 Correct 207 ms 228944 KB Output is correct
14 Correct 207 ms 228944 KB Output is correct
15 Correct 205 ms 228944 KB Output is correct
16 Correct 199 ms 228944 KB Output is correct
17 Correct 212 ms 228944 KB Output is correct
18 Correct 202 ms 228944 KB Output is correct
19 Correct 207 ms 228944 KB Output is correct
20 Correct 205 ms 229092 KB Output is correct
21 Correct 206 ms 229092 KB Output is correct
22 Correct 198 ms 229092 KB Output is correct
23 Correct 206 ms 229092 KB Output is correct
24 Correct 203 ms 229092 KB Output is correct
25 Correct 207 ms 229092 KB Output is correct
26 Correct 210 ms 229092 KB Output is correct
27 Correct 203 ms 229268 KB Output is correct
28 Correct 209 ms 229268 KB Output is correct
29 Correct 195 ms 229268 KB Output is correct
30 Correct 209 ms 229268 KB Output is correct
31 Correct 191 ms 229268 KB Output is correct
32 Correct 207 ms 229268 KB Output is correct
33 Correct 206 ms 229268 KB Output is correct
34 Correct 208 ms 229268 KB Output is correct
35 Correct 203 ms 229268 KB Output is correct
36 Correct 197 ms 229268 KB Output is correct
37 Correct 207 ms 229268 KB Output is correct
38 Correct 196 ms 229268 KB Output is correct
39 Correct 195 ms 229268 KB Output is correct
40 Correct 206 ms 229268 KB Output is correct
41 Correct 197 ms 229268 KB Output is correct
42 Correct 199 ms 229268 KB Output is correct
43 Correct 201 ms 229268 KB Output is correct
44 Correct 202 ms 229268 KB Output is correct
45 Correct 216 ms 229268 KB Output is correct
46 Correct 205 ms 229268 KB Output is correct
47 Correct 204 ms 229268 KB Output is correct
48 Correct 209 ms 229268 KB Output is correct
49 Correct 199 ms 229268 KB Output is correct
50 Correct 197 ms 229268 KB Output is correct
51 Correct 196 ms 229268 KB Output is correct
52 Correct 200 ms 229268 KB Output is correct
53 Correct 212 ms 229268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 207 ms 228472 KB Output is correct
2 Correct 207 ms 228600 KB Output is correct
3 Correct 214 ms 228708 KB Output is correct
4 Correct 209 ms 228708 KB Output is correct
5 Correct 209 ms 228708 KB Output is correct
6 Correct 215 ms 228732 KB Output is correct
7 Correct 206 ms 228732 KB Output is correct
8 Correct 208 ms 228800 KB Output is correct
9 Correct 208 ms 228804 KB Output is correct
10 Correct 213 ms 228852 KB Output is correct
11 Correct 207 ms 228944 KB Output is correct
12 Correct 205 ms 228944 KB Output is correct
13 Correct 207 ms 228944 KB Output is correct
14 Correct 207 ms 228944 KB Output is correct
15 Correct 205 ms 228944 KB Output is correct
16 Correct 199 ms 228944 KB Output is correct
17 Correct 212 ms 228944 KB Output is correct
18 Correct 202 ms 228944 KB Output is correct
19 Correct 207 ms 228944 KB Output is correct
20 Correct 205 ms 229092 KB Output is correct
21 Correct 206 ms 229092 KB Output is correct
22 Correct 198 ms 229092 KB Output is correct
23 Correct 206 ms 229092 KB Output is correct
24 Correct 203 ms 229092 KB Output is correct
25 Correct 207 ms 229092 KB Output is correct
26 Correct 210 ms 229092 KB Output is correct
27 Correct 203 ms 229268 KB Output is correct
28 Correct 209 ms 229268 KB Output is correct
29 Correct 195 ms 229268 KB Output is correct
30 Correct 209 ms 229268 KB Output is correct
31 Correct 191 ms 229268 KB Output is correct
32 Correct 207 ms 229268 KB Output is correct
33 Correct 206 ms 229268 KB Output is correct
34 Correct 208 ms 229268 KB Output is correct
35 Correct 203 ms 229268 KB Output is correct
36 Correct 197 ms 229268 KB Output is correct
37 Correct 207 ms 229268 KB Output is correct
38 Correct 196 ms 229268 KB Output is correct
39 Correct 195 ms 229268 KB Output is correct
40 Correct 206 ms 229268 KB Output is correct
41 Correct 197 ms 229268 KB Output is correct
42 Correct 199 ms 229268 KB Output is correct
43 Correct 201 ms 229268 KB Output is correct
44 Correct 202 ms 229268 KB Output is correct
45 Correct 216 ms 229268 KB Output is correct
46 Correct 205 ms 229268 KB Output is correct
47 Correct 204 ms 229268 KB Output is correct
48 Correct 209 ms 229268 KB Output is correct
49 Correct 199 ms 229268 KB Output is correct
50 Correct 197 ms 229268 KB Output is correct
51 Correct 196 ms 229268 KB Output is correct
52 Correct 200 ms 229268 KB Output is correct
53 Correct 212 ms 229268 KB Output is correct
54 Correct 221 ms 229268 KB Output is correct
55 Correct 219 ms 238796 KB Output is correct
56 Correct 199 ms 238796 KB Output is correct
57 Correct 219 ms 245092 KB Output is correct
58 Correct 267 ms 249208 KB Output is correct
59 Runtime error 539 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
60 Halted 0 ms 0 KB -