답안 #94879

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94879 2019-01-24T17:12:48 Z emphasis10 보물 찾기 (CEOI13_treasure2) C++14
0 / 100
2 ms 376 KB
#include "treasure.h"

int tmap[101][101]; //-1 : unknown 0 : no treasure 1: treasure

int totaltreasure;

void ecofind(int x1, int y1, int x2, int y2) {
	if (totaltreasure == 0) return;
	if (countTreasure(x1, y1, x2, y2) == (x2 - x1 + 1)*(y2 - y1 + 1)) {
		for (int i = x1; i <= x2; i++) {
			for (int j = y1; j <= y2; j++) tmap[i][j] = 1;
		}
		totaltreasure -= (x2 - x1 + 1)*(y2 - y1 + 1);
	} 
	else {
		if (x1 == x2) {
			tmap[x1][y1] = countTreasure(x1, y1, x2, y2);
			return;
		}
		int mid = (x1 + x2) / 2;
		ecofind(x1, y1, mid, mid);
		ecofind(mid + 1, y1, x2, mid);
		ecofind(x1, mid + 1, mid, y2);
		ecofind(mid + 1, mid + 1, x2, y2);
	}
}

void findTreasure (int N) {
	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) tmap[i][j] = -1;

	totaltreasure = countTreasure(1, 1, N, N);
	if (N == 1) {
		if (countTreasure(1, 1, 1, 1) == 1) Report(1, 1);
		return;
	}

	if (N % 2 == 0) ecofind(1, 1, N, N);
	else ecofind(1, 1, N - 1, N - 1);

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (tmap[i][j] == -1) tmap[i][j] = countTreasure(i, j, i, j);
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (tmap[i][j] == 1) Report(i, j);
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Error - check the range of the parameters of countTreasure() : r1 = 3, c1 = 4, r2 = 3, c2 = 2
2 Incorrect 1 ms 256 KB Error - check the range of the parameters of countTreasure() : r1 = 4, c1 = 5, r2 = 4, c2 = 3
3 Incorrect 2 ms 376 KB Error - check the range of the parameters of countTreasure() : r1 = 1, c1 = 3, r2 = 1, c2 = 1
4 Incorrect 1 ms 256 KB Error - check the range of the parameters of countTreasure() : r1 = 3, c1 = 4, r2 = 3, c2 = 2
5 Incorrect 2 ms 376 KB Error - check the range of the parameters of countTreasure() : r1 = 3, c1 = 4, r2 = 3, c2 = 2
6 Incorrect 2 ms 376 KB Error - check the range of the parameters of countTreasure() : r1 = 1, c1 = 3, r2 = 1, c2 = 1
7 Incorrect 2 ms 376 KB Error - check the range of the parameters of countTreasure() : r1 = 1, c1 = 3, r2 = 1, c2 = 1
8 Incorrect 2 ms 376 KB Error - check the range of the parameters of countTreasure() : r1 = 1, c1 = 12, r2 = 6, c2 = 6
9 Incorrect 2 ms 376 KB Error - check the range of the parameters of countTreasure() : r1 = 3, c1 = 4, r2 = 3, c2 = 2
10 Incorrect 2 ms 376 KB Error - check the range of the parameters of countTreasure() : r1 = 3, c1 = 4, r2 = 3, c2 = 2