Submission #42491

#TimeUsernameProblemLanguageResultExecution timeMemory
42491nonocut보물 찾기 (CEOI13_treasure2)C++14
73 / 100
5 ms2016 KiB
#include "treasure.h"
#include<bits/stdc++.h>
using namespace std;

int s1[105][105], s2[105][105], s3[105][105], s4[105][105];
int a[105][105];
map<int,map<int,map<int,map<int,int>>>> mp;

int get(int r1,int c1,int r2,int c2) {
    if(!mp[r1][c1][r2][c2]) mp[r1][c1][r2][c2] = countTreasure(r1,c1,r2,c2);
    return mp[r1][c1][r2][c2];
}

void findTreasure (int N) {
    //section1
    for(int i=1;i<=N/2+2;i++) {
        for(int j=1;j<=N/2+1;j++) {
            s1[i][j] = get(i,j,N,N);
        }
    }
    //section 2
    for(int i=N/2;i<=N;i++) {
        for(int j=1;j<=N/2+1;j++) {
            s2[i][j] = get(1,j,i,N);
        }
    }
    //section 3
    for(int i=1;i<=N/2+1;i++) {
        for(int j=N/2;j<=N;j++) {
            s3[i][j] = get(i,1,N,j);
        }
    }
    //section 4
    for(int i=N/2;i<=N;i++) {
        for(int j=N/2;j<=N;j++) {
            s4[i][j] = get(1,1,i,j);
        }
    }
    for(int i=1;i<=N;i++) {
        for(int j=1;j<=N;j++) {
            if(i<=N/2 && j<=N/2) a[i][j] = s1[i][j] - s1[i+1][j] - s1[i][j+1] + s1[i+1][j+1];
            if(i>=N/2+1 && j<=N/2) a[i][j] = s2[i][j] - s2[i-1][j] - s2[i][j+1] + s2[i-1][j+1];
            if(i<=N/2 && j>=N/2+1) a[i][j] = s3[i][j] - s3[i+1][j] - s3[i][j-1] + s3[i+1][j-1];
            if(i>=N/2+1 && j>=N/2+1) a[i][j] = s4[i][j] - s4[i-1][j] - s4[i][j-1] + s4[i-1][j-1];
            if(a[i][j]) Report(i,j);
//            printf("%d",a[i][j]);
        }
//        printf("\n");
    }
}

Compilation message (stderr)

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 timeMemoryGrader output
Fetching results...