Submission #40777

#TimeUsernameProblemLanguageResultExecution timeMemory
40777hsb154Treasure (different grader from official contest) (CEOI13_treasure2)C++14
19 / 100
2 ms624 KiB
#include "treasure.h"
int countTreasure(int r1, int c1, int r2, int c2);
void Report(int r, int c);
bool map[101][101];
void bSearch(int r1,int c1,int r2,int c2,int cnt) {
	if (r1 == r2&&c1 == c2) {
		map[r1][c2] = 1;
		return;
	}
	int rmid = (r1 + r2) / 2;
	int cmid = (c1 + c2) / 2;
	int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0;


	if (r1 <= rmid&&c1 <= cmid) {//왼쪽 위
		cnt1 = countTreasure(r1, c1, rmid, cmid);
		if(cnt1!=0)
			bSearch(r1, c1, rmid, cmid,cnt1);
	}
	if (rmid + 1 <= r2&&c1 <= cmid&&cnt!=cnt1) {//왼쪽아래
		cnt2 = countTreasure(rmid + 1, c1, r2, cmid);
		if(cnt2!=0)
			bSearch(rmid + 1, c1, r2, cmid,cnt2);
	}
	if (r1 <= rmid&&cmid + 1 <= c2&&cnt!=cnt1+cnt2) {//오른쪽 위
		cnt3 = countTreasure(r1, cmid + 1, rmid, c2);
		if(cnt3!=0)
			bSearch(r1, cmid + 1, rmid, c2,cnt3);
	}
	if (rmid + 1 <= r2&&cmid + 1 <= c2) {//오른쪽 아래
		cnt4 = cnt - cnt1 - cnt2 - cnt3;
		if(cnt4!=0)
			bSearch(rmid + 1, cmid + 1, r2, c2,cnt4);
	}
}
void findTreasure (int N) {
	int cnt = countTreasure(1, 1, N, N);
	bSearch(1,1,N,N,cnt);
	
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (map[i][j] == 1)
				Report(i, j);
		}
	}
}

Compilation message (stderr)

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)");
                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...