# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
250928 | imeimi2000 | Treasure (different grader from official contest) (CEOI13_treasure2) | C++17 | 11 ms | 1024 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 <map>
using namespace std;
int n;
struct qs {
int q[4];
bool operator<(const qs &x) const {
for (int i = 0; i < 4; ++i) {
if (q[i] < x.q[i]) return 1;
if (q[i] > x.q[i]) return 0;
}
return 0;
}
};
int getCnt(int x1, int y1, int x2, int y2) {
static map<qs, int> mp;
qs x = { x1, y1, x2, y2 };
if (mp.find(x) != mp.end())
return mp[x];
return mp[x] = countTreasure(x1, y1, x2, y2);
}
int ans[101][101];
void findTreasure (int N) {
n = N;
int m = (1 + n) / 2;
for (int i = 1; i < m; ++i) {
for (int j = 1; j < m; ++j) {
ans[i][j] = getCnt(i, j, n, n) - getCnt(i + 1, j, n, n)
- getCnt(i, j + 1, n, n) + getCnt(i + 1, j + 1, n, n);
}
}
for (int i = 1; i < m; ++i) {
for (int j = m + 1; j <= n; ++j) {
ans[i][j] = getCnt(i, 1, n, j) - getCnt(i + 1, 1, n, j)
- getCnt(i, 1, n, j - 1) + getCnt(i + 1, 1, n, j - 1);
}
}
for (int i = m + 1; i <= n; ++i) {
for (int j = 1; j < m; ++j) {
ans[i][j] = getCnt(1, j, i, n) - getCnt(1, j, i - 1, n)
- getCnt(1, j + 1, i, n) + getCnt(1, j + 1, i - 1, n);
}
}
for (int i = m + 1; i <= n; ++i) {
for (int j = m + 1; j <= n; ++j) {
ans[i][j] = getCnt(1, 1, i, j) - getCnt(1, 1, i - 1, j)
- getCnt(1, 1, i, j - 1) + getCnt(1, 1, i - 1, j - 1);
}
}
for (int i = 1; i < m; ++i) {
ans[i][m] = getCnt(i, m, n, n) - getCnt(i + 1, m, n, n);
for (int j = m + 1; j <= n; ++j) ans[i][m] -= ans[i][j];
ans[m][i] = getCnt(m, i, n, n) - getCnt(m, i + 1, n, n);
for (int j = m + 1; j <= n; ++j) ans[m][i] -= ans[j][i];
}
for (int i = m + 1; i <= n; ++i) {
ans[i][m] = getCnt(1, 1, i, m) - getCnt(1, 1, i - 1, m);
for (int j = 1; j < m; ++j) ans[i][m] -= ans[i][j];
ans[m][i] = getCnt(1, 1, m, i) - getCnt(1, 1, m, i - 1);
for (int j = 1; j < m; ++j) ans[m][i] -= ans[j][i];
}
int mid = getCnt(1, 1, n, n);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
mid -= ans[i][j];
}
}
ans[m][m] = mid;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
if (ans[i][j]) Report(i, j);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |