# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
470606 | nicolaalexandra | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 9 ms | 972 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 <bits/stdc++.h>
#include "treasure.h"
#define DIM 110
#define mp make_pair
using namespace std;
int a[DIM][DIM];
map <pair<pair<int,int>,pair<int,int> >, int > f;
int n,i,j;
void findTreasure (int n) {
for (int i=1;i<=n/2;i++)
for (int j=1;j<=n/2;j++){
if (f[mp(mp(i,j),mp(n,n))])
a[i][j] += f[mp(mp(i,j),mp(n,n))];
else {
int val = countTreasure(i,j,n,n);
a[i][j] += val;
f[mp(mp(i,j),mp(n,n))] = val;
}
if (f[mp(mp(i,j+1),mp(n,n))])
a[i][j] -= f[mp(mp(i,j+1),mp(n,n))];
else {
int val = countTreasure(i,j+1,n,n);
a[i][j] -= val;
f[mp(mp(i,j+1),mp(n,n))] = val;
}
if (f[mp(mp(i+1,j),mp(n,n))])
a[i][j] -= f[mp(mp(i+1,j),mp(n,n))];
else {
int val = countTreasure(i+1,j,n,n);
a[i][j] -= val;
f[mp(mp(i+1,j),mp(n,n))] = val;
}
if (f[mp(mp(i+1,j+1),mp(n,n))])
a[i][j] += f[mp(mp(i+1,j+1),mp(n,n))];
else {
int val = countTreasure(i+1,j+1,n,n);
a[i][j] += val;
f[mp(mp(i+1,j+1),mp(n,n))] = val;
}
}
for (int i=1;i<=n/2;i++)
for (int j=n/2+1;j<=n;j++){
if (f[mp(mp(i,1),mp(n,j))])
a[i][j] += f[mp(mp(i,1),mp(n,j))];
else {
int val = countTreasure(i,1,n,j);
a[i][j] += val;
f[mp(mp(i,1),mp(n,j))] = val;
}
if (f[mp(mp(i,1),mp(n,j-1))])
a[i][j] -= f[mp(mp(i,1),mp(n,j-1))];
else {
int val = countTreasure(i,1,n,j-1);
a[i][j] -= val;
f[mp(mp(i,1),mp(n,j-1))] = val;
}
if (f[mp(mp(i+1,1),mp(n,j))])
a[i][j] -= f[mp(mp(i+1,1),mp(n,j))];
else {
int val = countTreasure(i+1,1,n,j);
a[i][j] -= val;
f[mp(mp(i+1,1),mp(n,j))] = val;
}
if (f[mp(mp(i+1,1),mp(n,j-1))])
a[i][j] += f[mp(mp(i+1,1),mp(n,j-1))];
else {
int val = countTreasure(i+1,1,n,j-1);
a[i][j] += val;
f[mp(mp(i+1,1),mp(n,j-1))] = val;
}
}
for (int i=n/2+1;i<=n;i++)
for (int j=1;j<=n/2;j++){
if (f[mp(mp(1,j),mp(i,n))])
a[i][j] += f[mp(mp(1,j),mp(i,n))];
else {
int val = countTreasure(1,j,i,n);
a[i][j] += val;
f[mp(mp(1,j),mp(i,n))] = val;
}
if (f[mp(mp(1,j),mp(i-1,n))])
a[i][j] -= f[mp(mp(1,j),mp(i-1,n))];
else {
int val = countTreasure(1,j,i-1,n);
a[i][j] -= val;
f[mp(mp(1,j),mp(i-1,n))] = val;
}
if (f[mp(mp(1,j+1),mp(i,n))])
a[i][j] -= f[mp(mp(1,j+1),mp(i,n))];
else {
int val = countTreasure(1,j+1,i,n);
a[i][j] -= val;
f[mp(mp(1,j+1),mp(i,n))] = val;
}
if (f[mp(mp(1,j+1),mp(i-1,n))])
a[i][j] += f[mp(mp(1,j+1),mp(i-1,n))];
else {
int val = countTreasure(1,j+1,i-1,n);
a[i][j] += val;
f[mp(mp(1,j+1),mp(i-1,n))] = val;
}
}
for (int i=n/2+1;i<=n;i++)
for (int j=n/2+1;j<=n;j++){
if (f[mp(mp(1,1),mp(i,j))])
a[i][j] += f[mp(mp(1,1),mp(i,j))];
else {
int val = countTreasure(1,1,i,j);
a[i][j] += val;
f[mp(mp(1,1),mp(i,j))] = val;
}
if (f[mp(mp(1,1),mp(i-1,j))])
a[i][j] -= f[mp(mp(1,1),mp(i-1,j))];
else {
int val = countTreasure(1,1,i-1,j);
a[i][j] -= val;
f[mp(mp(1,1),mp(i-1,j))] = val;
}
if (f[mp(mp(1,1),mp(i,j-1))])
a[i][j] -= f[mp(mp(1,1),mp(i,j-1))];
else {
int val = countTreasure(1,1,i,j-1);
a[i][j] -= val;
f[mp(mp(1,1),mp(i,j-1))] = val;
}
if (f[mp(mp(1,1),mp(i-1,j-1))])
a[i][j] += f[mp(mp(1,1),mp(i-1,j-1))];
else {
int val = countTreasure(1,1,i-1,j-1);
a[i][j] += val;
f[mp(mp(1,1),mp(i-1,j-1))] = val;
}
}
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
if (a[i][j])
Report (i,j);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |