Submission #759672

# Submission time Handle Problem Language Result Execution time Memory
759672 2023-06-16T14:39:48 Z doowey Treasure (different grader from official contest) (CEOI13_treasure2) C++14
34 / 100
6 ms 980 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;
    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 ++ ){
            cur_value = 0;
            if(i > n / 2 && j > n / 2){
                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(i <= n / 2 && j > n / 2){
                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(i > n / 2 && j <= n / 2){
                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);
}

Compilation message

treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:33:9: warning: unused variable 'cost0' [-Wunused-variable]
   33 |     int cost0;
      |         ^~~~~
treasure.cpp:34:9: warning: unused variable 'cost1' [-Wunused-variable]
   34 |     int cost1;
      |         ^~~~~
treasure.cpp:35:9: warning: unused variable 'cost2' [-Wunused-variable]
   35 |     int cost2;
      |         ^~~~~
treasure.cpp:36:9: warning: unused variable 'cost3' [-Wunused-variable]
   36 |     int cost3;
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 212 KB Output is partially correct - N = 5, K = 585, score = 1
2 Partially correct 1 ms 212 KB Output is partially correct - N = 10, K = 7821, score = 1
3 Partially correct 1 ms 340 KB Output is partially correct - N = 15, K = 37800, score = 4
4 Partially correct 1 ms 340 KB Output is partially correct - N = 16, K = 48609, score = 4
5 Partially correct 2 ms 556 KB Output is partially correct - N = 55, K = 6421660, score = 4
6 Partially correct 3 ms 596 KB Output is partially correct - N = 66, K = 13268509, score = 4
7 Partially correct 4 ms 724 KB Output is partially correct - N = 77, K = 24521445, score = 4
8 Partially correct 5 ms 852 KB Output is partially correct - N = 88, K = 41753889, score = 4
9 Partially correct 6 ms 948 KB Output is partially correct - N = 99, K = 66787350, score = 4
10 Partially correct 6 ms 980 KB Output is partially correct - N = 100, K = 69517701, score = 4