답안 #100471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100471 2019-03-11T13:39:05 Z square1001 무지개나라 (APIO17_rainbow) C++14
11 / 100
25 ms 908 KB
#include "rainbow.h"
#include <queue>
#include <vector>
#include <cassert>
using namespace std;

const vector<int> dx = { 0, 1, 0, -1 };
const vector<int> dy = { 1, 0, -1, 0 };

bool river[55][55], vis[55][55];
void init(int R, int C, int sr, int sc, int M, char *S) {
	assert(R <= 50 && C <= 50);
	--sr, --sc;
	river[sr][sc] = true;
	for(int i = 0; i < M; ++i) {
		if(S[i] == 'N') --sr;
		if(S[i] == 'S') ++sr;
		if(S[i] == 'W') --sc;
		if(S[i] == 'E') ++sc;
		river[sr][sc] = true;
	}
}

int colour(int ar, int ac, int br, int bc) {
	--ar, --ac;
	for(int i = ar; i < br; ++i) {
		for(int j = ac; j < bc; ++j) {
			vis[i][j] = false;
		}
	}
	int ans = 0;
	for(int i = ar; i < br; ++i) {
		for(int j = ac; j < bc; ++j) {
			if(vis[i][j] || river[i][j]) continue;
			queue<pair<int, int> > que; que.push(make_pair(i, j));
			vis[i][j] = true;
			while(!que.empty()) {
				pair<int, int> u = que.front(); que.pop();
				for(int k = 0; k < 4; ++k) {
					int tx = u.first + dx[k], ty = u.second + dy[k];
					if(ar <= tx && tx < br && ac <= ty && ty < bc && !river[tx][ty] && !vis[tx][ty]) {
						vis[tx][ty] = true;
						que.push(make_pair(tx, ty));
					}
				}
			}
			++ans;
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 19 ms 384 KB Output is correct
4 Correct 25 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 18 ms 384 KB Output is correct
12 Correct 14 ms 384 KB Output is correct
13 Correct 11 ms 384 KB Output is correct
14 Correct 22 ms 512 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 19 ms 384 KB Output is correct
4 Correct 25 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 18 ms 384 KB Output is correct
12 Correct 14 ms 384 KB Output is correct
13 Correct 11 ms 384 KB Output is correct
14 Correct 22 ms 512 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Runtime error 3 ms 908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 19 ms 384 KB Output is correct
4 Correct 25 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 18 ms 384 KB Output is correct
12 Correct 14 ms 384 KB Output is correct
13 Correct 11 ms 384 KB Output is correct
14 Correct 22 ms 512 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Runtime error 3 ms 908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -