Submission #99447

# Submission time Handle Problem Language Result Execution time Memory
99447 2019-03-04T07:10:15 Z mzhao Dango Maker (JOI18_dango_maker) C++11
13 / 100
3 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define D(x...) printf(x)
#else
#define D(x...)
#endif

int R, C, G[3100][3100], ans;
bool f[3100][3100][2]; // 0 is horizontal, 1 is vertical
bool vis[3100][3100][2];

int col[2];

void dfs(int x, int y, int z, int c) {
	assert(x >= 0 && x < R && y >= 0 && y < C);
	if (vis[x][y][z]) return;
	vis[x][y][z] = 1;
	col[c]++;
	if (z) {
		if (f[x][y][0]) dfs(x, y, 0, !c);
		if (y > 0 && f[x+1][y-1][0]) dfs(x+1, y-1, 0, !c);
		if (y > 1 && f[x+2][y-2][0]) dfs(x+2, y-2, 0, !c);
	} else {
		if (f[x][y][1]) dfs(x, y, 1, !c);
		if (x > 0 && f[x-1][y+1][1]) dfs(x-1, y+1, 1, !c);
		if (x > 1 && f[x-2][y+2][1]) dfs(x-2, y+2, 1, !c);
	}
}

int main() {
	scanf("%d%d", &R, &C);
	for (int i = 0; i < R; i++) {
		char A;
		scanf("\n");
		for (int j = 0; j < C; j++) {
			scanf("%c", &A);
			if (A == 'G') G[i][j] = 1;
			if (A == 'W') G[i][j] = 2;
		}
	}
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) {
			if (i < R-2 && G[i][j] == 0 && G[i+1][j] == 1 && G[i+2][j] == 2)
				f[i][j][1] = 1;
			if (j < C-2 && G[i][j] == 0 && G[i][j+1] == 1 && G[i][j+2] == 2)
				f[i][j][0] = 1;
		}
	}
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) D("%d", f[i][j][0]);
		D("\n");
	}
	D("\n");
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) D("%d", f[i][j][1]);
		D("\n");
	}
	D("\n");
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < 2; k++) {
				if (!vis[i][j][k] && f[i][j][k]) {
					col[0] = col[1] = 0;
					dfs(i, j, k, 0);
					ans += max(col[0], col[1]);
				}
			}
		}
	}
	printf("%d\n", ans);
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &R, &C);
  ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("\n");
   ~~~~~^~~~~~
dango_maker.cpp:38:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%c", &A);
    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 3 ms 512 KB Output is correct
34 Incorrect 2 ms 384 KB Output isn't correct
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 3 ms 512 KB Output is correct
34 Incorrect 2 ms 384 KB Output isn't correct
35 Halted 0 ms 0 KB -