Submission #250928

# Submission time Handle Problem Language Result Execution time Memory
250928 2020-07-19T13:10:23 Z imeimi2000 Treasure (different grader from official contest) (CEOI13_treasure2) C++17
100 / 100
11 ms 1024 KB
#include "treasure.h"
#include <map>
 
using namespace std;
 
int n;
 
struct qs {
    int q[4];
    bool operator<(const qs &x) const {
        for (int i = 0; i < 4; ++i) {
            if (q[i] < x.q[i]) return 1;
            if (q[i] > x.q[i]) return 0;
        }
        return 0;
    }
};
 
int getCnt(int x1, int y1, int x2, int y2) {
    static map<qs, int> mp;
    qs x = { x1, y1, x2, y2 };
    if (mp.find(x) != mp.end())
        return mp[x];
    return mp[x] = countTreasure(x1, y1, x2, y2);
}
 
int ans[101][101];
 
void findTreasure (int N) {
    n = N;
    int m = (1 + n) / 2;
    for (int i = 1; i < m; ++i) {
        for (int j = 1; j < m; ++j) {
            ans[i][j] = getCnt(i, j, n, n) - getCnt(i + 1, j, n, n)
                        - getCnt(i, j + 1, n, n) + getCnt(i + 1, j + 1, n, n);
        }
    }
    for (int i = 1; i < m; ++i) {
        for (int j = m + 1; j <= n; ++j) {
            ans[i][j] = getCnt(i, 1, n, j) - getCnt(i + 1, 1, n, j)
                        - getCnt(i, 1, n, j - 1) + getCnt(i + 1, 1, n, j - 1);
        }
    }
    for (int i = m + 1; i <= n; ++i) {
        for (int j = 1; j < m; ++j) {
            ans[i][j] = getCnt(1, j, i, n) - getCnt(1, j, i - 1, n)
                        - getCnt(1, j + 1, i, n) + getCnt(1, j + 1, i - 1, n);
        }
    }
    for (int i = m + 1; i <= n; ++i) {
        for (int j = m + 1; j <= n; ++j) {
            ans[i][j] = getCnt(1, 1, i, j) - getCnt(1, 1, i - 1, j)
                        - getCnt(1, 1, i, j - 1) + getCnt(1, 1, i - 1, j - 1);
        }
    }
    for (int i = 1; i < m; ++i) {
        ans[i][m] = getCnt(i, m, n, n) - getCnt(i + 1, m, n, n);
        for (int j = m + 1; j <= n; ++j) ans[i][m] -= ans[i][j];
        
        ans[m][i] = getCnt(m, i, n, n) - getCnt(m, i + 1, n, n);
        for (int j = m + 1; j <= n; ++j) ans[m][i] -= ans[j][i];
    }
    
    for (int i = m + 1; i <= n; ++i) {
        ans[i][m] = getCnt(1, 1, i, m) - getCnt(1, 1, i - 1, m);
        for (int j = 1; j < m; ++j) ans[i][m] -= ans[i][j];
        
        ans[m][i] = getCnt(1, 1, m, i) - getCnt(1, 1, m, i - 1);
        for (int j = 1; j < m; ++j) ans[m][i] -= ans[j][i];
    }
    
    int mid = getCnt(1, 1, n, n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            mid -= ans[i][j];
        }
    }
    ans[m][m] = mid;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (ans[i][j]) Report(i, j);
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct - N = 5, K = 289, score = 10
2 Correct 0 ms 384 KB Output is correct - N = 10, K = 4475, score = 10
3 Correct 0 ms 384 KB Output is correct - N = 15, K = 22289, score = 10
4 Correct 0 ms 384 KB Output is correct - N = 16, K = 28928, score = 10
5 Correct 3 ms 512 KB Output is correct - N = 55, K = 4005289, score = 10
6 Correct 4 ms 640 KB Output is correct - N = 66, K = 8305803, score = 10
7 Correct 5 ms 768 KB Output is correct - N = 77, K = 15383161, score = 10
8 Correct 8 ms 896 KB Output is correct - N = 88, K = 26244416, score = 10
9 Correct 11 ms 1024 KB Output is correct - N = 99, K = 42032201, score = 10
10 Correct 10 ms 1024 KB Output is correct - N = 100, K = 43760000, score = 10