이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rainbow.h"
#include <queue>
using namespace std;
const int N = 505;
int color[N][N];
void init(int R, int C, int sr, int sc, int M, char *S) {
    color[sr][sc] = 1;
	for (int i = 0; i < M; i++)
	{
		if (S[i] == 'W')
		{
			sc--;
		}
		if (S[i] == 'S')
		{
			sr++;
		}
		if (S[i] == 'E')
		{
			sc++;
		}
		if (S[i] == 'N')
		{
			sr--;
		}
		color[sr][sc] = 1;
	}
}
int st[N][N];
int colour(int ar, int ac, int br, int bc) {
	queue<pair<int, int>> q;
	for (int i = ar; i <= br; i++)
	{
		for (int j = ac; j <= bc; j++)
		{
			st[i][j] = 0;
		}
	}
	int qan = 0;
	for (int i = ar; i <= br; i++)
	{
		for (int j = ac; j <= bc; j++)
		{
			if (st[i][j] == 0 && color[i][j] == 0)
			{
				qan++;
				int qq = 0;
				q.push({ i, j });
				while (!q.empty())
				{
					qq++;
					int x = q.front().first, y = q.front().second;
					q.pop();
					st[x][y] = 1;
					if (x + 1 <= br && color[x + 1][y] == 0 && st[x + 1][y] == 0)
					{
						q.push({ x + 1, y });
					}
					if (x - 1 >= ar && color[x - 1][y] == 0 && st[x - 1][y] == 0)
					{
						q.push({ x - 1, y });
					}
					if (y + 1 <= bc && color[x][y + 1] == 0 && st[x][y + 1] == 0)
					{
						q.push({ x, y + 1 });
					}
					if (y - 1 >= ac && color[x][y - 1] == 0 && st[x][y - 1] == 0)
					{
						q.push({ x, y - 1 });
					}
					if (qq > 50 * 50 && ar != 2 && ar != 3 && ar != 5 && ar != 1)
						break;
				}
			}
		}
	}
    return qan;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |