답안 #40578

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40578 2018-02-05T07:15:16 Z geeyehappy 보물 찾기 (CEOI13_treasure2) C++14
38 / 100
2 ms 676 KB
#include "treasure.h"

int total;
int temp = 0;
int flag = 0;
struct info {
	int y;
	int x;
};
struct info sarr[100005];
int cur = -1;
void findfunc(int r, int c, int y, int x, int cnt) {// 세로길이, 가로길이, 시작y, 시작x
	
	if (cnt == 0 || flag == -1) return;
	else if (cnt == r*c) {
		for (int i = 0; i < r; ++i) {
			for (int j = 0; j < c; ++j) {
				sarr[++cur].y = y + i;
				sarr[cur].x = x + j;
			}
		}
		temp += cnt;
		if (temp == total) flag = -1;
		return;
	}

	int tr, tc;
	if (r % 2 == 1)tr = r / 2 + 1;
	else tr = r / 2;
	if (c % 2 == 1) tc = c / 2 + 1;
	else tc = c / 2;

	int area_1 = countTreasure(y, x, y + tr - 1, x + tc - 1); // 왼쪽 상단
	if (area_1) findfunc(tr, tc, y, x, area_1);

	int area_2 = countTreasure(y, x, y + tr - 1, x + c - 1) - area_1; //오른족 상단
	if (area_2) findfunc(tr,c-tc, y, x + tc, area_2);

	int area_3 = countTreasure(y, x, y + r - 1, x + tc - 1) - area_1; //왼쪽 하단
	if (area_3) findfunc(r - tr, tc, y + tr, x, area_3);

	int area_4 = countTreasure(y, x, y + r - 1, x + c - 1) - (area_1 + area_2 + area_3);
	if (area_4) findfunc(r - tr, c - tc, y + tr, x + tc, area_4);

}

void findTreasure(int N) {
	int cnt = countTreasure(1, 1, N, N);
	total = cnt;

	findfunc(N, N, 1, 1, cnt);
	for (int i = 0; i <= cur; ++i) {
		Report(sarr[i].y, sarr[i].x);
	}
	return;
}

Compilation message

grader.c: In function 'int main()':
grader.c:63:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         my_assert(strlen(A[i]+1) == N, "each line of the map must contain N zeroes or ones (before loop)");
                                  ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct - N = 5, K = 782, score = 0
2 Incorrect 1 ms 352 KB Output isn't correct - N = 10, K = 12123, score = 0
3 Partially correct 2 ms 424 KB Output is partially correct - N = 15, K = 26514, score = 8
4 Correct 2 ms 460 KB Output is correct - N = 16, K = 27156, score = 10
5 Incorrect 2 ms 532 KB Output isn't correct - N = 55, K = 12026735, score = 0
6 Incorrect 2 ms 532 KB Output isn't correct - N = 66, K = 23956203, score = 0
7 Correct 2 ms 604 KB Output is correct - N = 77, K = 10804992, score = 10
8 Correct 2 ms 676 KB Output is correct - N = 88, K = 14050969, score = 10
9 Incorrect 2 ms 676 KB Output isn't correct - N = 99, K = 133153399, score = 0
10 Incorrect 2 ms 676 KB Output isn't correct - N = 100, K = 140416574, score = 0