# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53137 | SpaimaCarpatilor | Treasure (different grader from official contest) (CEOI13_treasure2) | C++17 | 6 ms | 1356 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "treasure.h"
#include<bits/stdc++.h>
using namespace std;
static int N, K, s[109][109], a[109][109], partS[109][109];
static map < pair < pair < int, int >, pair < int, int > >, int > mp;
int query (int a, int b, int c, int d)
{
pair < pair < int, int >, pair < int, int > > curr = {{a, b}, {c, d}};
if (mp.count (curr))
{
//printf ("(%d %d) (%d, %d)\n", a, b, c, d);
return mp[curr];
}
int x = countTreasure (a, b, c, d);
mp[curr] = x;
return x;
}
void findTreasure (int N)
{
int K = N / 2;
for (int i=1; i<=K + 1; i++)
for (int j=1; j<=K + 1; j++)
s[i][j] = query (i, j, N, N);
for (int i=1; i<=K; i++)
for (int j=1; j<=K; j++)
a[i][j] = s[i][j] - s[i + 1][j] - s[i][j + 1] + s[i + 1][j + 1];
for (int i=1; i<=K + 1; i++)
for (int j=K; j<=N; j++)
s[i][j] = query (i, 1, N, j);
for (int i=1; i<=K; i++)
for (int j=K + 1; j<=N; j++)
a[i][j] = s[i][j] - s[i + 1][j] - s[i][j - 1] + s[i + 1][j - 1];
for (int i=K; i<=N; i++)
for (int j=1; j<=K + 1; j++)
s[i][j] = query (1, j, i, N);
for (int i=K + 1; i<=N; i++)
for (int j=1; j<=K; j++)
a[i][j] = s[i][j] - s[i - 1][j] - s[i][j + 1] + s[i - 1][j + 1];
for (int i=K; i<=N; i++)
for (int j=K; j<=N; j++)
s[i][j] = query (1, 1, i, j);
for (int i=K + 1; i<=N; i++)
for (int j=K + 1; j<=N; j++)
a[i][j] = s[i][j] - s[i - 1][j] - s[i][j - 1] + s[i - 1][j - 1];
for (int i=1; i<=N; i++)
for (int j=1; j<=N; j++)
if (a[i][j] > 0)
Report (i, j);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |