# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
470606 | nicolaalexandra | 보물 찾기 (CEOI13_treasure2) | C++14 | 9 ms | 972 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |