# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
78739 | Plurm | 보물 찾기 (CEOI13_treasure2) | C++11 | 30 ms | 1780 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "treasure.h"
using namespace std;
int knownval[128][128];
class Hasher{
public:
const size_t operator()(const tuple<int,int,int,int>& x) const{
return get<0>(x) + get<1>(x) + get<2>(x) + get<3>(x);
}
};
unordered_map<tuple<int,int,int,int>,int,Hasher> cache;
int n;
int getval(int a,int b,int c,int d){
if(a > c || b > d || a == 0 || b == 0 || c == 0 || d == 0 || a == n+1 || b == n+1 || c == n+1 || d == n+1) return 0;
if(cache.find(make_tuple(a,b,c,d)) == cache.end()){
int res = countTreasure(a,b,c,d);
cache[make_tuple(a,b,c,d)] = res;
return res;
}else{
return cache[make_tuple(a,b,c,d)];
}
}
void findTreasure(int N){
memset(knownval,-1,sizeof(knownval));
n = N;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
knownval[i][j] = getval(1,1,n,n) - (getval(1,1,i-1,j) + getval(1,1,i,n) - getval(1,1,i,j) + getval(i+1,j,n,n) + getval(1,1,n,j-1) - getval(1,1,i-1,j-1));
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(knownval[i][j] == 1){
Report(i,j);
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |