Submission #165065

# Submission time Handle Problem Language Result Execution time Memory
165065 2019-11-25T03:24:50 Z Berted Dango Maker (JOI18_dango_maker) C++14
13 / 100
2 ms 504 KB
#include <iostream>
#include <queue>
#define pii pair<int,int>
#define fst first
#define snd second
using namespace std;
int n,m,to=0;string mp[3001]={};
bool bt[3001][3001][2]={};
queue<pii> q;
bool ck(int y,int x,int dr)
{
	if (y>=0 && y<n-(dr?2:0) && x>=0 && x<m-((!dr)?2:0))
	{
		return mp[y][x] == 'R' && mp[y+dr][x+(!dr)] == 'G' && mp[y+2*dr][x+2*(!dr)] == 'W';
	} 
	else {return 0;}
}
int main()
{
	cin>>n>>m;
	for (int i=0;i<n;i++) {cin>>mp[i];}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			if (ck(i,j,0) && !bt[i][j][0])
			{
				int to1 = 0,to2 = 0;
				q.push({i,j});
				while (!q.empty())
				{
					pii dt = q.front();q.pop();
					for (int i=0;i<3;i++)
					{
						if (!bt[dt.fst][dt.snd][0])
						{
							bt[dt.fst][dt.snd][0] = 1;
							to1++;
							for (int i=0;i<3;i++)
							{
								if (ck(dt.fst-i,dt.snd+i,1))
								{
									to2 += !bt[dt.fst-i][dt.snd+i][1];
									bt[dt.fst-i][dt.snd+i][1] = 1;
									for (int j=0;j<3;j++)
									{
										if (j==i) {continue;}
										if (ck(dt.fst-i+j,dt.snd+i-j,0))
										{
											q.push({dt.fst-i+j,dt.snd+i-j});
										}
									}
								}
							}
						}
					}
				}
				//cout<<i<<" "<<j<<" "<<to1<<" "<<to2<<"\n";
				to+=max(to1,to2);
			}
		}
	}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			if (ck(i,j,1) && !bt[i][j][1]) {to++;}
		}
	}
	cout<<to<<"\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 380 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 2 ms 504 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 504 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Incorrect 2 ms 376 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 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 380 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 2 ms 504 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 504 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Incorrect 2 ms 376 KB Output isn't correct
35 Halted 0 ms 0 KB -