# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
667895 | 600Mihnea | Treasure (different grader from official contest) (CEOI13_treasure2) | C++17 | 1 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "treasure.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 7;
int s[4][N][N];
bool deja = 0;
bool ok;
int n;
int get(int type, int r, int c)
{
if (type == 0)
{
if (r <= 0 || c <= 0)
{
return 0;
}
ok &= (s[type][r][c] != -1);
return s[type][r][c];
}
if (type == 1)
{
if (r <= 0 || c > n)
{
return 0;
}
ok &= (s[type][r][c] != -1);
return s[type][r][c];
}
if (type == 2)
{
if (r > n || c <= 0)
{
return 0;
}
ok &= (s[type][r][c] != -1);
return s[type][r][c];
}
if (type == 3)
{
if (r > n || c > n)
{
return 0;
}
ok &= (s[type][r][c] != -1);
return s[type][r][c];
}
assert(0);
}
int what(int r, int c)
{
ok = 1;
int sm;
sm = get(0, r, c) - get(0, r - 1, c) - get(0, r, c - 1) + get(0, r - 1, c - 1);
if (ok)
{
return sm;
}
ok = 1;
sm = get(1, r, c) - get(1, r - 1, c) - get(1, r, c + 1) + get(1, r - 1, c + 1);
if (ok)
{
return sm;
}
ok = 1;
sm = get(2, r, c) - get(2, r + 1, c) - get(2, r, c - 1) + get(2, r + 1, c - 1);
if (ok)
{
return sm;
}
ok = 1;
sm = get(3, r, c) - get(3, r + 1, c) - get(3, r, c + 1) + get(3, r + 1, c + 1);
if (ok)
{
return sm;
}
cout << "bad " << r << " " << c << "\n";
return 0;
/// assert(0);
}
void findTreasure(int nn)
{
n = nn;
for (int k = 0; k < 4; k++)
{
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
s[k][i][j] = -1;
}
}
}
assert(deja == 0);
deja = 1;
for (int i = 1; i <= n / 2; i++)
{
for (int j = 1; j <= n / 2 + 1; j++)
{
s[3][i][j] = countTreasure(i, j, n, n);
}
}
for (int i = 1; i <= n / 2; i++)
{
for (int j = n / 2; j < n; j++)
{
s[2][i][j] = countTreasure(i, 1, n, j);
}
s[2][i][n] = s[3][i][1];
}
for (int i = n / 2 - 1; i <= n; i++)
{
for (int j = 1; j <= n / 2 + 1; j++)
{
s[1][i][j] = countTreasure(1, j, i, n);
}
}
for (int i = n / 2 - 1; i <= n; i++)
{
for (int j = n / 2; j <= n; j++)
{
s[0][i][j] = countTreasure(1, 1, i, j);
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (what(i, j))
{
Report(i, j);
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |