#include "treasure.h"
#include <bits/stdc++.h>
using namespace std;
int ans[150][150], col[150], n, pref[150][150];
int save[102][102];
int query(int x, int y, int xi, int yi)
{
if(save[xi][yi] != -1) return save[xi][yi];
return save[xi][yi] = countTreasure(x, y, xi, yi);
}
void solve(int l, int r, int k)
{
if(!k) return;
if(l == r) col[l] = k;
else
{
int mid = (l + r)/2;
int A = query(1, 1, n, mid);
for(int i = 1; i < mid; i++) A -= col[i];
solve(l, mid, A), solve(mid + 1, r, k - A);
}
}
int qtd = 0;
void solve2(int id, int l, int r, int k)
{
if(!k) return;
if(k == r - l + 1)
{
for(int i = l; i <= r; i++) ans[i][id] = 1;
return;
}
if(l == r) ans[l][id] = k;
else
{
int mid = (l + r)/2;
int A = query(1, 1, mid, id);
qtd ++;
for(int i = 1; i <= id; i++)
for(int j = 1; j <= mid; j++)
A -= ans[j][i];
solve2(id, l, mid, A), solve2(id, mid + 1, r, k - A);
}
}
void findTreasure (int N)
{
n = N;
memset(save, -1, sizeof save);
//solve(1, N, query(1, 1, N, N));
int mid = (1 + n)/2;
for(int i = n; i >= 1; i--)
{
for(int j = n; j >= 1; j--)
{
if(i >= mid and j >= mid) pref[i][j] = countTreasure(1, 1, i, j);
else if(i >= mid and j <= mid)
pref[i][j] = pref[i][n] - countTreasure(1, j + 1, i, n);
else if(i <= mid and j >= mid)
pref[i][j] = pref[n][j] - countTreasure(i + 1, 1, n, j);
else if(i <= mid and j <= mid)
pref[i][j] = -1*(pref[n][n] - countTreasure(i + 1, j + 1, n, n) - pref[i][n] - pref[n][j]);
}
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
if(pref[i][j] - pref[i - 1][j] - pref[i][j - 1] + pref[i - 1][j - 1] > 0)
Report(i, j);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct - N = 5, K = 289, score = 10 |
2 |
Correct |
2 ms |
376 KB |
Output is correct - N = 10, K = 4475, score = 10 |
3 |
Correct |
2 ms |
396 KB |
Output is correct - N = 15, K = 22289, score = 10 |
4 |
Correct |
3 ms |
520 KB |
Output is correct - N = 16, K = 28928, score = 10 |
5 |
Correct |
2 ms |
520 KB |
Output is correct - N = 55, K = 4005289, score = 10 |
6 |
Correct |
2 ms |
520 KB |
Output is correct - N = 66, K = 8305803, score = 10 |
7 |
Correct |
2 ms |
600 KB |
Output is correct - N = 77, K = 15383161, score = 10 |
8 |
Correct |
3 ms |
600 KB |
Output is correct - N = 88, K = 26244416, score = 10 |
9 |
Correct |
3 ms |
776 KB |
Output is correct - N = 99, K = 42032201, score = 10 |
10 |
Correct |
2 ms |
776 KB |
Output is correct - N = 100, K = 43760000, score = 10 |