#include "treasure.h"
//#include"header.h"
int result[10009][4];
int rl;
void dfs(int remain, int si, int ei, int sj, int ej) {
if (ei < si)return;
if (ej < sj)return;
if (remain == (ei - si + 1) * (ej - sj + 1)) {
result[rl][0] = si;
result[rl][1] = ei;
result[rl][2] = sj;
result[rl][3] = ej;
rl++;
return;
}
if (remain == 0) {
return;
}
int mi = (si + ei) / 2;
int mj = (sj + ej) / 2;
int ab = countTreasure(si + 1, sj + 1, ei + 1, mj + 1);
int ac = countTreasure(si + 1, sj + 1, mi + 1, ej + 1);
int aa = countTreasure(si + 1, sj + 1, mi + 1, mj + 1);
dfs(aa, si, mi, sj, mj);
dfs(ab - aa, mi + 1, ei, sj, mj);
dfs(ac - aa, si, mi, mj+1, ej);
dfs(remain - ab - ac + aa, mi + 1, ei, mj + 1, ej);
}
void findTreasure(int N) {
int cnt = countTreasure(1, 1, N, N);
if (cnt == 0)return;
else {
rl = 0;
dfs(cnt, 0, N - 1, 0, N - 1);
while (rl--) {
for (int i = result[rl][0]; i <= result[rl][1]; i++) {
for (int j = result[rl][2]; j <= result[rl][3]; j++) {
Report(i + 1, j + 1);
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
5 ms |
256 KB |
Output is partially correct - N = 5, K = 608, score = 1 |
2 |
Partially correct |
5 ms |
256 KB |
Output is partially correct - N = 10, K = 9217, score = 1 |
3 |
Correct |
5 ms |
384 KB |
Output is correct - N = 15, K = 20154, score = 10 |
4 |
Correct |
4 ms |
384 KB |
Output is correct - N = 16, K = 20684, score = 10 |
5 |
Partially correct |
5 ms |
384 KB |
Output is partially correct - N = 55, K = 9027174, score = 1 |
6 |
Partially correct |
5 ms |
384 KB |
Output is partially correct - N = 66, K = 17978223, score = 1 |
7 |
Correct |
4 ms |
384 KB |
Output is correct - N = 77, K = 8114327, score = 10 |
8 |
Correct |
4 ms |
384 KB |
Output is correct - N = 88, K = 10552186, score = 10 |
9 |
Incorrect |
5 ms |
384 KB |
Output isn't correct - N = 99, K = 99891584, score = 0 |
10 |
Incorrect |
5 ms |
512 KB |
Output isn't correct - N = 100, K = 105339629, score = 0 |