답안 #775091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775091 2023-07-06T07:31:39 Z Sam_a17 무지개나라 (APIO17_rainbow) C++17
11 / 100
3000 ms 1856 KB
#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 });
        st[i][j] = true;
				while (!q.empty())
				{
					qq++;
					int x = q.front().first, y = q.front().second;
					q.pop();
					if (x + 1 <= br && color[x + 1][y] == 0 && st[x + 1][y] == 0)
					{
            st[x + 1][y] = true;
						q.push({ x + 1, y });
					}
					if (x - 1 >= ar && color[x - 1][y] == 0 && st[x - 1][y] == 0)
					{
            st[x - 1][y] = true;
						q.push({ x - 1, y });
					}
					if (y + 1 <= bc && color[x][y + 1] == 0 && st[x][y + 1] == 0)
					{
            st[x][y + 1] = true;
						q.push({ x, y + 1 });
					}
					if (y - 1 >= ac && color[x][y - 1] == 0 && st[x][y - 1] == 0)
					{
            st[x][y - 1] = true;
						q.push({ x, y - 1 });
					}
				}
			}
		}
	}
    return qan;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 308 KB Output is correct
2 Correct 4 ms 440 KB Output is correct
3 Correct 10 ms 524 KB Output is correct
4 Correct 10 ms 468 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 9 ms 436 KB Output is correct
12 Correct 7 ms 532 KB Output is correct
13 Correct 7 ms 468 KB Output is correct
14 Correct 4 ms 536 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Execution timed out 3075 ms 1856 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Runtime error 1 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 308 KB Output is correct
2 Correct 4 ms 440 KB Output is correct
3 Correct 10 ms 524 KB Output is correct
4 Correct 10 ms 468 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 9 ms 436 KB Output is correct
12 Correct 7 ms 532 KB Output is correct
13 Correct 7 ms 468 KB Output is correct
14 Correct 4 ms 536 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Runtime error 1 ms 468 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 308 KB Output is correct
2 Correct 4 ms 440 KB Output is correct
3 Correct 10 ms 524 KB Output is correct
4 Correct 10 ms 468 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 9 ms 436 KB Output is correct
12 Correct 7 ms 532 KB Output is correct
13 Correct 7 ms 468 KB Output is correct
14 Correct 4 ms 536 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Runtime error 1 ms 468 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -