Submission #11212

# Submission time Handle Problem Language Result Execution time Memory
11212 2014-11-19T00:30:47 Z gs14004 Treasure (different grader from official contest) (CEOI13_treasure2) C++
100 / 100
3 ms 2668 KB
#include "treasure.h"
#include <cstdlib>
#include <map>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int,int> pi;
typedef pair<pi,pi> pip;

map<pip,short> mp;
queue<pi> q;
int n;
short count2(int s, int e, int x, int y){
    if(mp.find(pip(pi(s,e),pi(x,y))) != mp.end()) return mp[pip(pi(s,e),pi(x,y))];
    return mp[pip(pi(s,e),pi(x,y))] = countTreasure(s,e,x,y);
}

void result(int x, int y, char t){
    if(t == '1') q.push(pi(x,y));
}

void findTreasure(int N)
{
    n = N;
    int half = N/2;
    for (int i=1; i<=half; i++) {
        int b1 = count2(i,1,N,N);
        int b2 = count2(i+1,1,N,N);
        for (int j=1; j<=half; j++) {
            int s3 = count2(i,j+1,N,N);
            int s4 = count2(i+1,j+1,N,N);
            result(i,j,abs(b1 - b2 - s3 + s4) + '0');
            b1 = s3;
            b2 = s4;
        }
        b1 = count2(i,1,N,N) - b1;
        b2 = count2(i+1,1,N,N) - b2;
        for (int j=half+1; j<=N; j++) {
            int s3 = count2(i,1,N,j);
            int s4 = count2(i+1,1,N,j);
            result(i,j,abs(b1 - b2 - s3 + s4) + '0');
            b1 = s3;
            b2 = s4;
        }
    }
    for (int j=1; j<=half; j++) {
        mp[pip(pi(1,j),pi(half,N))] = count2(1,j,N,N) - count2(half+1,j,N,N);
    }
    for (int j=half+1; j<=N; j++) {
        mp[pip(pi(1,1),pi(half,j))] = count2(1,1,N,j) - count2(half+1,1,N,j);
    }
    mp[pip(pi(1,half+1),pi(half,N))] = count2(1,half+1,N,N) - count2(half+1,half+1,N,N);
    for (int i=half+1; i<=N; i++) {
        int b1 = count2(1,1,i-1,N);
        int b2 = count2(1,1,i,N);
        for (int j=1; j<=half; j++) {
            int s3 = count2(1,j+1,i-1,N);
            int s4 = count2(1,j+1,i,N);
            result(i,j,abs(b1 - b2 - s3 + s4) + '0');
            b1 = s3;
            b2 = s4;
        }
        b1 = count2(1,1,i-1,N) - b1;
        b2 = count2(1,1,i,N) - b2;
        for (int j=half+1; j<=N; j++) {
            int s3 = count2(1,1,i-1,j);
            int s4 = count2(1,1,i,j);
            result(i,j,abs(b1 - b2 - s3 + s4) + '0');
            b1 = s3;
            b2 = s4;
        }
    }
    while (!q.empty()) {
        Report(q.front().first,q.front().second);
        q.pop();
    }
    return;
}

Compilation message

grader.c: In function 'int main()':
grader.c:63:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         my_assert(strlen(A[i]+1) == N, "each line of the map must contain N zeroes or ones (before loop)");
                                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2008 KB Output is correct - N = 5, K = 289, score = 10
2 Correct 0 ms 2008 KB Output is correct - N = 10, K = 4475, score = 10
3 Correct 0 ms 2008 KB Output is correct - N = 15, K = 22289, score = 10
4 Correct 0 ms 2008 KB Output is correct - N = 16, K = 28928, score = 10
5 Correct 0 ms 2272 KB Output is correct - N = 55, K = 4005289, score = 10
6 Correct 0 ms 2272 KB Output is correct - N = 66, K = 8305803, score = 10
7 Correct 3 ms 2404 KB Output is correct - N = 77, K = 15383161, score = 10
8 Correct 0 ms 2536 KB Output is correct - N = 88, K = 26244416, score = 10
9 Correct 3 ms 2668 KB Output is correct - N = 99, K = 42032201, score = 10
10 Correct 3 ms 2668 KB Output is correct - N = 100, K = 43760000, score = 10