Submission #58743

# Submission time Handle Problem Language Result Execution time Memory
58743 2018-07-19T06:23:56 Z YaDon4ick Dango Maker (JOI18_dango_maker) C++11
13 / 100
4 ms 752 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 4 ms 468 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 672 KB Output is correct
4 Correct 2 ms 728 KB Output is correct
5 Correct 0 ms 728 KB Output is correct
6 Correct 3 ms 728 KB Output is correct
7 Correct 4 ms 728 KB Output is correct
8 Correct 3 ms 728 KB Output is correct
9 Correct 2 ms 728 KB Output is correct
10 Correct 3 ms 728 KB Output is correct
11 Correct 3 ms 728 KB Output is correct
12 Correct 3 ms 728 KB Output is correct
13 Correct 2 ms 728 KB Output is correct
14 Correct 2 ms 728 KB Output is correct
15 Correct 3 ms 728 KB Output is correct
16 Correct 2 ms 728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 468 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 672 KB Output is correct
4 Correct 2 ms 728 KB Output is correct
5 Correct 0 ms 728 KB Output is correct
6 Correct 3 ms 728 KB Output is correct
7 Correct 4 ms 728 KB Output is correct
8 Correct 3 ms 728 KB Output is correct
9 Correct 2 ms 728 KB Output is correct
10 Correct 3 ms 728 KB Output is correct
11 Correct 3 ms 728 KB Output is correct
12 Correct 3 ms 728 KB Output is correct
13 Correct 2 ms 728 KB Output is correct
14 Correct 2 ms 728 KB Output is correct
15 Correct 3 ms 728 KB Output is correct
16 Correct 2 ms 728 KB Output is correct
17 Correct 2 ms 728 KB Output is correct
18 Correct 3 ms 728 KB Output is correct
19 Correct 2 ms 748 KB Output is correct
20 Correct 3 ms 748 KB Output is correct
21 Correct 3 ms 748 KB Output is correct
22 Correct 3 ms 748 KB Output is correct
23 Correct 3 ms 748 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 3 ms 748 KB Output is correct
26 Correct 2 ms 748 KB Output is correct
27 Correct 3 ms 752 KB Output is correct
28 Correct 3 ms 752 KB Output is correct
29 Correct 3 ms 752 KB Output is correct
30 Correct 3 ms 752 KB Output is correct
31 Correct 2 ms 752 KB Output is correct
32 Correct 2 ms 752 KB Output is correct
33 Correct 3 ms 752 KB Output is correct
34 Incorrect 3 ms 752 KB Output isn't correct
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 468 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 672 KB Output is correct
4 Correct 2 ms 728 KB Output is correct
5 Correct 0 ms 728 KB Output is correct
6 Correct 3 ms 728 KB Output is correct
7 Correct 4 ms 728 KB Output is correct
8 Correct 3 ms 728 KB Output is correct
9 Correct 2 ms 728 KB Output is correct
10 Correct 3 ms 728 KB Output is correct
11 Correct 3 ms 728 KB Output is correct
12 Correct 3 ms 728 KB Output is correct
13 Correct 2 ms 728 KB Output is correct
14 Correct 2 ms 728 KB Output is correct
15 Correct 3 ms 728 KB Output is correct
16 Correct 2 ms 728 KB Output is correct
17 Correct 2 ms 728 KB Output is correct
18 Correct 3 ms 728 KB Output is correct
19 Correct 2 ms 748 KB Output is correct
20 Correct 3 ms 748 KB Output is correct
21 Correct 3 ms 748 KB Output is correct
22 Correct 3 ms 748 KB Output is correct
23 Correct 3 ms 748 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 3 ms 748 KB Output is correct
26 Correct 2 ms 748 KB Output is correct
27 Correct 3 ms 752 KB Output is correct
28 Correct 3 ms 752 KB Output is correct
29 Correct 3 ms 752 KB Output is correct
30 Correct 3 ms 752 KB Output is correct
31 Correct 2 ms 752 KB Output is correct
32 Correct 2 ms 752 KB Output is correct
33 Correct 3 ms 752 KB Output is correct
34 Incorrect 3 ms 752 KB Output isn't correct
35 Halted 0 ms 0 KB -