Submission #759667

# Submission time Handle Problem Language Result Execution time Memory
759667 2023-06-16T14:31:54 Z doowey Treasure (different grader from official contest) (CEOI13_treasure2) C++14
0 / 100
2 ms 468 KB
#include <bits/stdc++.h>
#include "treasure.h"

using namespace std;

typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair

map<pair<pii,pii>, int> Q;

int ask(int i0, int j0, int i1, int j1){
    if(i0 > i1 || j0 > j1) return 0;
    return countTreasure(i0,j0,i1,j1);
    pair<pii, pii> rect = mp(mp(i0,j0), mp(i1,j1));
    if(Q.count(rect)){
        return Q[rect];
    }
    return Q[rect]=countTreasure(i0,j0,i1,j1);
}

int n;

int get_cost(int i0, int j0, int i1, int j1){
    if(i0 > i1 || j0 > j1) return 0;
    //if(Q.count(mp(mp(i0,j0), mp(i1,j1)))) return 0;
    return n * n - (i1 - i0 + 1) * (j1 - j0 + 1) + 1;
}

void findTreasure (int _n) {
    n = _n;
    int cost0;
    int cost1;
    int cost2;
    int cost3;
    int cur_value;
    vector<pii> ans;
    for(int i = 1; i <= n; i ++ ){
        for(int j = 1; j <= n; j ++ ){
            cost0 = get_cost(1, 1, i, j) + get_cost(1, 1, i - 1, j) + get_cost(1, 1, i, j - 1) + get_cost(1, 1, i - 1, j - 1);
            cost1 = get_cost(1, j, i, n) + get_cost(1, j, i - 1, n) + get_cost(1, j + 1, i, n) + get_cost(1, j + 1, i - 1, n);
            cost2 = get_cost(i, 1, n, j) + get_cost(i, 1, n, j - 1) + get_cost(i + 1, 1, n, j) + get_cost(i + 1, 1, n, j - 1);
            cost3 = get_cost(i, j, n, n) + get_cost(i + 1, j, n, n) + get_cost(i, j + 1, n, n) + get_cost(i + 1, j + 1, n, n);
            cur_value = 0;
            if(cost0 <= cost1 && cost0 <= cost2 && cost0 <= cost3){
                cur_value = ask(1, 1, i, j) - ask(1, 1, i - 1, j) - ask(1, 1, i, j - 1) + ask(1, 1, i - 1, j - 1);
            }
            else if(cost1 <= cost2 && cost1 <= cost3){
                cur_value = ask(1, j, i, n) - ask(1, j, i - 1, n) - ask(1, j + 1, i, n) + ask(1, j + 1, i - 1, n);
            }
            else if(cost2 <= cost3){
                cur_value = ask(i, 1, n, j) - ask(i, 1, n, j - 1) - ask(i + 1, 1, n, j) + ask(i + 1, 1, n, j - 1);
            }
            else{
                cur_value = ask(i, j, n, n) - ask(i + 1, j, n, n) - ask(i, j + 1, n, n) + ask(i + 1, j + 1, n, n);
            }
            if(cur_value == 1)
                ans.push_back(mp(i, j));
        }
    }
    for(auto x : ans) Report(x.fi, x.se);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct - N = 5, K = 1183, score = 0
2 Incorrect 1 ms 212 KB Output isn't correct - N = 10, K = 17868, score = 0
3 Incorrect 0 ms 212 KB Output isn't correct - N = 15, K = 89703, score = 0
4 Incorrect 0 ms 212 KB Output isn't correct - N = 16, K = 115680, score = 0
5 Incorrect 1 ms 340 KB Output isn't correct - N = 55, K = 16029783, score = 0
6 Incorrect 1 ms 340 KB Output isn't correct - N = 66, K = 33223180, score = 0
7 Incorrect 1 ms 340 KB Output isn't correct - N = 77, K = 61549807, score = 0
8 Incorrect 1 ms 340 KB Output isn't correct - N = 88, K = 104977632, score = 0
9 Incorrect 1 ms 340 KB Output isn't correct - N = 99, K = 168157407, score = 0
10 Incorrect 2 ms 468 KB Output isn't correct - N = 100, K = 175039968, score = 0