#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 |
1 |
Partially correct |
1 ms |
204 KB |
Output is partially correct - N = 5, K = 495, score = 8 |
2 |
Partially correct |
1 ms |
332 KB |
Output is partially correct - N = 10, K = 5821, score = 8 |
3 |
Partially correct |
1 ms |
296 KB |
Output is partially correct - N = 15, K = 26880, score = 8 |
4 |
Partially correct |
1 ms |
332 KB |
Output is partially correct - N = 16, K = 34273, score = 8 |
5 |
Partially correct |
3 ms |
460 KB |
Output is partially correct - N = 55, K = 4217920, score = 8 |
6 |
Partially correct |
4 ms |
588 KB |
Output is partially correct - N = 66, K = 8668573, score = 8 |
7 |
Partially correct |
6 ms |
716 KB |
Output is partially correct - N = 77, K = 15962895, score = 8 |
8 |
Partially correct |
7 ms |
844 KB |
Output is partially correct - N = 88, K = 27102241, score = 8 |
9 |
Partially correct |
9 ms |
972 KB |
Output is partially correct - N = 99, K = 43260000, score = 8 |
10 |
Partially correct |
9 ms |
948 KB |
Output is partially correct - N = 100, K = 45017701, score = 8 |