Submission #464528

# Submission time Handle Problem Language Result Execution time Memory
464528 2021-08-13T10:59:39 Z zxcvbnm Treasure (different grader from official contest) (CEOI13_treasure2) C++14
22 / 100
7 ms 936 KB
#include "treasure.h"
#include <bits/stdc++.h>
using namespace std;
int n;
bool ans[105][105];
map<array<int, 4>, int> call;
int query(int x1, int y1, int x2, int y2) {
    if (call.count({x1, y1, x2, y2})) {
        return call[{x1, y1, x2, y2}];
    }
    return call[{x1, y1, x2, y2}] = countTreasure(x1, y1, x2, y2);
}
void findTreasure (int N) {
    n = N;
//    for(int i = 1; i <= n; i++) {
//        for(int j = 1; j <= n; j++) {
//            if (query(i, j, i, j)) {
//                ans[i][j] = true;
//            }
//        }
//    }
//
    for(int i = 0; i < n; i++) {
        int cnt = query(i+1, 1, i+1, n);
        if (cnt == n) {
            for(int j = 1; j <= n; j++) {
                ans[i+1][j] = true;
            }
            continue;
        }
//        cout << cnt << "\n";
        int curr = 1;
        int l = 1, r = n;
        while(curr <= cnt) {
            r = n;
            int rep = 0;
            while(l <= r) {
                int mid = (l + r) / 2;
                int x = query(i+1, 1, i+1, mid);
                if (x == mid) {
                    for(int j = 1; j <= mid; j++) {
                        ans[i+1][j] = true;
                    }
                    curr = mid+1;
                    l = mid+1;
                    goto Out;
                }
                if (x >= curr) {
                    rep = mid;
                    r = mid - 1;
                } else {
                    l = mid + 1;
                }
            }
            curr++;
            assert(rep != 0);
//            cout << "add " << i << " " << rep << "\n";
            ans[i+1][rep] = true;
            l = rep+1;
            Out:;
        }
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            if (ans[i][j]) {
                Report(i, j);
            }
//            cerr << ans[i][j] << " ";
        }
//        cerr << "\n";
    }

//    int cnt = countTreasure(1, 1, N, N);
//    if(cnt > 0) Report(1, 1);
}
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 204 KB Output is partially correct - N = 5, K = 526, score = 1
2 Partially correct 0 ms 204 KB Output is partially correct - N = 10, K = 8172, score = 1
3 Partially correct 0 ms 204 KB Output is partially correct - N = 15, K = 31600, score = 4
4 Partially correct 1 ms 204 KB Output is partially correct - N = 16, K = 48553, score = 4
5 Partially correct 2 ms 488 KB Output is partially correct - N = 55, K = 8648842, score = 1
6 Partially correct 3 ms 588 KB Output is partially correct - N = 66, K = 18139098, score = 1
7 Partially correct 3 ms 588 KB Output is partially correct - N = 77, K = 26063589, score = 4
8 Partially correct 3 ms 588 KB Output is partially correct - N = 88, K = 32813726, score = 4
9 Partially correct 7 ms 936 KB Output is partially correct - N = 99, K = 93039423, score = 1
10 Partially correct 7 ms 936 KB Output is partially correct - N = 100, K = 96855064, score = 1