Submission #58742

# Submission time Handle Problem Language Result Execution time Memory
58742 2018-07-19T06:07:48 Z YaDon4ick Dango Maker (JOI18_dango_maker) C++14
13 / 100
3 ms 804 KB
//By Don4ick
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qwer1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = 3005;
const int M = N * N * 2;

using namespace std;

bool was[2][N][N];
int n, m, cnt0, cnt1;
string s[N];

bool check(int x, int y, int type)
{
	if (x < 0 || x > n || y < 0 || y > m)
		return false;
	if (type == 0)	
	{
		if (y >= m - 2)
			return false;
		return s[x][y] == 'R' && s[x][y + 1] == 'G' && s[x][y + 2] == 'W';	
	}
	else
	{
		if (x >= n - 2)
			return false;
		return s[x][y] == 'R' && s[x + 1][y] == 'G' && s[x + 2][y] == 'W';
	}
}

void dfs(int x, int y, int type)
{
	was[type][x][y] = true;
	if (type == 0)
	{
		cnt0++;
		for (int i = 0; i < 3; i++)
		{
			int tx = x - i, ty = y + i;
			if (check(tx, ty, 1) && !was[1][tx][ty])
				dfs(tx, ty, 1);
		}
	}	
	else
	{
		cnt1++;
		for (int i = 0; i < 3; i++)
		{
			int tx = x + i, ty = y - i;
			if (check(tx, ty, 0) && !was[0][tx][ty])
				dfs(tx, ty, 0);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	//~solve
	int ans = 0; 
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (check(i, j, 0) && !was[0][i][j])
			{
				cnt0 = cnt1 = 0;
				dfs(i, j, 0);
				ans += max(cnt0, cnt1);
			}
			if (check(i, j, 1) && !was[1][i][j])
			{
				cnt0 = cnt1 = 0;
				dfs(i, j, 1);
				ans += max(cnt0, cnt1);
	    	}
		}
	}
	//~result
	cout << ans << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 612 KB Output is correct
3 Correct 3 ms 636 KB Output is correct
4 Correct 2 ms 636 KB Output is correct
5 Correct 3 ms 636 KB Output is correct
6 Correct 3 ms 704 KB Output is correct
7 Correct 2 ms 728 KB Output is correct
8 Correct 3 ms 764 KB Output is correct
9 Correct 3 ms 764 KB Output is correct
10 Correct 2 ms 764 KB Output is correct
11 Correct 3 ms 764 KB Output is correct
12 Correct 3 ms 764 KB Output is correct
13 Correct 3 ms 764 KB Output is correct
14 Correct 3 ms 764 KB Output is correct
15 Correct 3 ms 764 KB Output is correct
16 Correct 3 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 612 KB Output is correct
3 Correct 3 ms 636 KB Output is correct
4 Correct 2 ms 636 KB Output is correct
5 Correct 3 ms 636 KB Output is correct
6 Correct 3 ms 704 KB Output is correct
7 Correct 2 ms 728 KB Output is correct
8 Correct 3 ms 764 KB Output is correct
9 Correct 3 ms 764 KB Output is correct
10 Correct 2 ms 764 KB Output is correct
11 Correct 3 ms 764 KB Output is correct
12 Correct 3 ms 764 KB Output is correct
13 Correct 3 ms 764 KB Output is correct
14 Correct 3 ms 764 KB Output is correct
15 Correct 3 ms 764 KB Output is correct
16 Correct 3 ms 764 KB Output is correct
17 Correct 3 ms 764 KB Output is correct
18 Correct 3 ms 764 KB Output is correct
19 Correct 3 ms 764 KB Output is correct
20 Correct 3 ms 764 KB Output is correct
21 Correct 2 ms 764 KB Output is correct
22 Correct 3 ms 764 KB Output is correct
23 Correct 2 ms 764 KB Output is correct
24 Correct 2 ms 764 KB Output is correct
25 Correct 3 ms 764 KB Output is correct
26 Correct 3 ms 764 KB Output is correct
27 Correct 2 ms 764 KB Output is correct
28 Correct 2 ms 764 KB Output is correct
29 Correct 2 ms 804 KB Output is correct
30 Correct 3 ms 804 KB Output is correct
31 Correct 3 ms 804 KB Output is correct
32 Correct 3 ms 804 KB Output is correct
33 Correct 2 ms 804 KB Output is correct
34 Incorrect 3 ms 804 KB Output isn't correct
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 612 KB Output is correct
3 Correct 3 ms 636 KB Output is correct
4 Correct 2 ms 636 KB Output is correct
5 Correct 3 ms 636 KB Output is correct
6 Correct 3 ms 704 KB Output is correct
7 Correct 2 ms 728 KB Output is correct
8 Correct 3 ms 764 KB Output is correct
9 Correct 3 ms 764 KB Output is correct
10 Correct 2 ms 764 KB Output is correct
11 Correct 3 ms 764 KB Output is correct
12 Correct 3 ms 764 KB Output is correct
13 Correct 3 ms 764 KB Output is correct
14 Correct 3 ms 764 KB Output is correct
15 Correct 3 ms 764 KB Output is correct
16 Correct 3 ms 764 KB Output is correct
17 Correct 3 ms 764 KB Output is correct
18 Correct 3 ms 764 KB Output is correct
19 Correct 3 ms 764 KB Output is correct
20 Correct 3 ms 764 KB Output is correct
21 Correct 2 ms 764 KB Output is correct
22 Correct 3 ms 764 KB Output is correct
23 Correct 2 ms 764 KB Output is correct
24 Correct 2 ms 764 KB Output is correct
25 Correct 3 ms 764 KB Output is correct
26 Correct 3 ms 764 KB Output is correct
27 Correct 2 ms 764 KB Output is correct
28 Correct 2 ms 764 KB Output is correct
29 Correct 2 ms 804 KB Output is correct
30 Correct 3 ms 804 KB Output is correct
31 Correct 3 ms 804 KB Output is correct
32 Correct 3 ms 804 KB Output is correct
33 Correct 2 ms 804 KB Output is correct
34 Incorrect 3 ms 804 KB Output isn't correct
35 Halted 0 ms 0 KB -