#include "treasure.h"
bool c[120][120];
int dp[120][120];
int find (int idx, int L, int R, int cnt = -1) {
if (cnt == -1) {
cnt = countTreasure (1, L, idx, R - 1) - dp[idx - 1][R - 1] + dp[idx - 1][L - 1];
}
if (cnt == (R - L)) {
for (int j = L; j < R; j++) {
c[idx][j] = 1;
}
return cnt;
}
if (cnt == 0)
return cnt;
int mid = (L + R) >> 1;
int x = find (idx, mid, R);
find (idx, L, mid, cnt - x);
return cnt;
}
void findTreasure (int N) {
for (int i = 1; i <= N; i++) {
find (i, 1, N + 1);
for (int j = 1; j <= N; j++) {
dp[i][j] = c[i][j] + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
}
}
for (int i = 1; i <= N; i++)
for (int j = 1; j <= N; j++)
if (c[i][j])
Report (i, j);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
376 KB |
Output is partially correct - N = 5, K = 422, score = 8 |
2 |
Partially correct |
2 ms |
376 KB |
Output is partially correct - N = 10, K = 5628, score = 8 |
3 |
Correct |
2 ms |
456 KB |
Output is correct - N = 15, K = 16894, score = 10 |
4 |
Correct |
2 ms |
476 KB |
Output is correct - N = 16, K = 20189, score = 10 |
5 |
Partially correct |
2 ms |
540 KB |
Output is partially correct - N = 55, K = 6302965, score = 4 |
6 |
Partially correct |
2 ms |
672 KB |
Output is partially correct - N = 66, K = 13149452, score = 4 |
7 |
Correct |
2 ms |
672 KB |
Output is correct - N = 77, K = 6773013, score = 10 |
8 |
Correct |
2 ms |
672 KB |
Output is correct - N = 88, K = 8911254, score = 10 |
9 |
Partially correct |
3 ms |
672 KB |
Output is partially correct - N = 99, K = 68532788, score = 4 |
10 |
Partially correct |
2 ms |
784 KB |
Output is partially correct - N = 100, K = 71919559, score = 4 |