제출 #257510

#제출 시각아이디문제언어결과실행 시간메모리
257510Saboon보물 찾기 (CEOI13_treasure2)C++14
38 / 100
1 ms384 KiB
#include <bits/stdc++.h>
#include "treasure.h"
using namespace std;
typedef long long ll;

const int maxn = 100 + 10;

bool mark[maxn][maxn];

void search(int l, int r, int lo, int hi){
	if (r <= l or hi <= lo)
		return;
	int tot = (r-l) * (hi-lo);
	int tre = countTreasure(l+1, lo+1, r, hi);
	if (tre == 0)
		return;
	if (tre == tot){
		for (int i = l; i < r; i++)
			for (int j = lo; j < hi; j++)
				mark[i][j] = 1;
		return;
	}
	int m1 = (l+r)>>1, m2 = (lo+hi)>>1;
	search(l,m1,lo,m2);
	search(l,m1,m2,hi);
	search(m1,r,lo,m2);
	search(m1,r,m2,hi);
}
	
void findTreasure(int n){
	search(0, n, 0, n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (mark[i][j])
				Report(i+1,j+1);
}
#Verdict Execution timeMemoryGrader output
Fetching results...