Submission #4530

# Submission time Handle Problem Language Result Execution time Memory
4530 2013-10-20T07:08:57 Z tncks0121 Treasure (different grader from official contest) (CEOI13_treasure2) C++
80 / 100
0 ms 1444 KB
#include "treasure.h"
#include <stdio.h>
#include <memory.h>
int A[105][105], B[105][105], C[105][105], D[105][105], R[105][105];
int S[105][105];

void findTreasure (int N) {
    int i, j;
    
    int T = N/2+1;
    
    // 각 사분면에서 최선의 경우를 가져옴
    for(i = 1; i <= T; i++) {
        for(j = 1; j <= T; j++) A[i][j] = countTreasure(i, j, N, N);
        for(j = T; j <= N; j++) B[i][j] = countTreasure(i, 1, N, j);
    }
    
    for(i = T; i <= N; i++) {
        for(j = 1; j <= T; j++) C[i][j] = countTreasure(1, j, i, N);
        for(j = T; j <= N; j++) D[i][j] = countTreasure(1, 1, i, j);
    }
    
    // 그러면 r = T or c = T인 십자가 제외하고 모든 게 다 나옴
    for(i = T-1; i > 0; i--) {
        for(j = T-1; j > 0; j--) R[i][j] = A[i][j] - A[i][j+1] - A[i+1][j] + A[i+1][j+1];
        for(j = T+1; j <= N; j++) R[i][j] = B[i][j] - B[i][j-1] - B[i+1][j] + B[i+1][j-1];
    }
    
    for(i = T+1; i <= N; i++) {
        for(j = T-1; j > 0; j--) R[i][j] = C[i][j] - C[i][j+1] - C[i-1][j] + C[i-1][j+1];
        for(j = T+1; j <= N; j++) R[i][j] = D[i][j] - D[i][j-1] - D[i-1][j] + D[i-1][j-1];
    }
    
    // r = T, c > T인 십자가 처리
    memset(S, 0, sizeof S);
    for(i = 1; i < T; i++) for(j = T+1; j <= N; j++) S[i][j] = S[i-1][j] + R[i][j];
    for(j = N; j >= T+1; j--) R[T][j] = D[T][j] - D[T][j-1] - S[T-1][j];
    
    // 그럼 c > T인 경우는 다 처리가 끝났고 c <= T만 남았음
    // 이제 r < T, c = T인 경우 처리
    memset(S, 0, sizeof S);
    for(i = 1; i < T; i++) {
        R[i][T] = A[i][T] - A[i+1][T];
        for(j = T+1; j <= N; j++) R[i][T] -= R[i][j];
    }
    
    // r > T, c = T인 경우 처리. 위와 똑같이 해줄 수 있음
    memset(S, 0, sizeof S);
    for(i = T+1; i <= N; i++) {
        R[i][T] = C[i][T] - C[i-1][T];
        for(j = T+1; j <= N; j++) R[i][T] -= R[i][j];
    }
    
    // 이제 c < T인 경우만 남았음. r = T, c < T인 직선 처리
    memset(S, 0, sizeof S);
    for(i = N; i >= T; i--) for(j = N; j > 0; j--) S[i][j] = S[i+1][j] + S[i][j+1] - S[i+1][j+1] + R[i][j];
    for(j = T-1; j > 0; j--) R[T][j] = A[T][j] - A[T][j+1] - S[T+1][j] + S[T+1][j+1];
    
    
    // r = c = T 부분 (정가운데) 처리
    R[T][T] = A[T][T] + B[T][T] + C[T][T] + D[T][T] - A[1][1];
    for(i = 1; i <= N; i++) if(i != T) R[T][T] -= (R[i][T] + R[T][i]);
    R[T][T] /= 3;
    /*
    puts("");
    for(i = 1; i <= N; i++) {
        printf("%3d ", i);
        for(j = 1; j <= N; j++) {
            printf("%3d",R[i][j]);
        }
        puts("");
    }*/
    
    for(i = 1; i <= N; i++) {
        for(j = 1; j <= N; j++) {
            if(R[i][j] == 1) Report(i, j);
        }
    }
}

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 Incorrect 0 ms 1444 KB Output is partially correct - N = 5, K = 360, score = 8
2 Incorrect 0 ms 1444 KB Output is partially correct - N = 10, K = 4996, score = 8
3 Incorrect 0 ms 1444 KB Output is partially correct - N = 15, K = 24000, score = 8
4 Incorrect 0 ms 1444 KB Output is partially correct - N = 16, K = 31009, score = 8
5 Incorrect 0 ms 1444 KB Output is partially correct - N = 55, K = 4088560, score = 8
6 Incorrect 0 ms 1444 KB Output is partially correct - N = 66, K = 8449684, score = 8
7 Incorrect 0 ms 1444 KB Output is partially correct - N = 77, K = 15611544, score = 8
8 Incorrect 0 ms 1444 KB Output is partially correct - N = 88, K = 26585329, score = 8
9 Incorrect 0 ms 1444 KB Output is partially correct - N = 99, K = 42517500, score = 8
10 Incorrect 0 ms 1444 KB Output is partially correct - N = 100, K = 44260201, score = 8