# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
667923 | 600Mihnea | Treasure (different grader from official contest) (CEOI13_treasure2) | C++17 | 1 ms | 468 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;
int ask(int r1, int c1, int r2, int c2)
{
if (r1 > r2 || c1 > c2)
{
return 0;
}
return countTreasure(r1, c1, r2, c2);
}
const int N = 100 + 7;
int ul[N][N];
int ur[N][N];
int dl[N][N];
int dr[N][N];
void findTreasure(int n)
{
int total = ask(1, 1, n, n);
int half = (n + 1) / 2;
for (int i = 1; i <= half; i++)
{
for (int j = 1; j <= half; j++)
{
dr[i][j] = ask(i, j, n, n); /// pe [1, half] and [1, half]
}
}
for (int i = half; i <= n; i++)
{
for (int j = 1; j <= half; j++)
{
ur[i][j] = ask(1, j, i, n); /// pe [half + 1, n] and [1, half]
}
}
for (int i = half; i <= n; i++)
{
for (int j = half; j <= n; j++)
{
ul[i][j] = ask(1, 1, i, j); /// pe [half + 1, n] and [half + 1, n]
}
}
for (int i = 1; i <= half; i++)
{
for (int j = half; j <= n; j++)
{
dl[i][j] = ask(i, 1, n, j); /// pe [1, half] and [half + 1, n]
}
}
for (int i = 1; i <= half; i++)
{
for (int j = 1; j < half; j++)
{
dl[i][j] = dl[i][n] - dr[i][j + 1];
}
}
for (int i = half; i <= n; i++)
{
for (int j = 1; j < half; j++)
{
ul[i][j] = ul[i][n] - ur[i][j + 1];
}
}
for (int i = 1; i <= half - 1; i++)
{
for (int j = 1; j <= n; j++)
{
ul[i][j] = ul[n][j] - dl[i + 1][j];
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
int val_ij = ul[i][j] - ul[i - 1][j] - ul[i][j - 1] + ul[i - 1][j - 1];
if (val_ij)
{
Report(i, j);
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |