답안 #680985

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680985 2023-01-12T07:46:42 Z Cross_Ratio 보물 찾기 (CEOI13_treasure2) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
//#include "treasure.h"
using namespace std;
int B[105][105][4];
map<array<int, 4>, int> M;
int N;
int q(int a, int b, int c, int d) {
    if(M.count({a, b, c, d})) return M[{a, b, c, d}];
    if(a==1&&b==1&&d==N&&M.count({1, 1, N, N}) && M.count({c+1, 1, N, N})) {
        return M[{1, 1, N, N}] - M[{c+1, 1, N, N}];
    }
    
    int v = countTreasure(a, b, c, d);
    M[{a, b, c, d}] = v;
    return v;
}
void r(int a, int b) {
    Report(a, b);
}
int C[105][105];
int D[105][4];
int E[105][4];
int sum[105];
void findTreasure(int _N) {
    N = _N;
    if(N==1) {
        if(q(1, 1, 1, 1)) r(1, 1);
        return;
    }
    int d = N / 2;
    if(N%2==1) d++;
    vector<array<int, 2>> ans;
    //1 ~ d, d+1 ~ N
    int i, j;
    for(i=d;i<=N;i++) {
        for(j=d;j<=N;j++) {
            B[i][j][0] = q(1, 1, i, j);
        }
    }
    for(i=d+1;i<=N;i++) {
        for(j=d+1;j<=N;j++) {
            int v = B[i][j][0] - B[i][j-1][0] - B[i-1][j][0] + B[i-1][j-1][0];
            if(v) {
                ans.push_back({i, j});
                C[i][j] = 1;
                D[i][0]++;
                E[j][0]++;
                sum[0]++;
            }
        }
    }

    for(i=d;i<=N;i++) {
        for(j=1;j<=d;j++) {
            B[i][j][1] = q(1, j, i, N);
        }
        if(i==d) B[i][d+1][1] = q(1, d+1, N, N) - sum[0];
        else {
            B[i][d+1][1] = B[i-1][d+1][1] + D[i][0];
        }
    }
    for(i=d+1;i<=N;i++) {
        for(j=1;j<=d;j++) {
            int v = B[i][j][1] - B[i-1][j][1] - B[i][j+1][1] + B[i-1][j+1][1];
            if(v) {
                ans.push_back({i, j});
                C[i][j] = 1;
                D[i][1]++;
                E[j][1]++;
                sum[1]++;
            }
        }
    }

    for(i=1;i<=d;i++) {
        for(j=1;j<=d+1;j++) {
            B[i][j][2] = q(i, j, N, N);
        }
    }
    B[d+1][d+1][2] = sum[0];
    for(j=d;j>=1;j--) B[i][j][2] = B[i][j+1][2] + E[j][1];
    for(i=1;i<=d;i++) {
        for(j=1;j<=d;j++) {
            int v = B[i][j][2] - B[i+1][j][2] - B[i][j+1][2] + B[i+1][j+1][2];
            if(v) {
                ans.push_back({i, j});
                C[i][j] = 1;
                D[i][2]++;
                E[j][2]++;
                sum[2]++;
            }
        }
    }

    for(i=1;i<=d;i++) {
        for(j=d+1;j<=N;j++) {
            B[i][j][3] = q(i, 1, N, j);
        }
    }
    B[d+1][d][3] = sum[1];
    for(i=d;i>=1;i--) B[i][d][3] = B[i+1][d][3] + D[i][2];
    for(j=d+1;j<=N;j++) B[d+1][j][3] = B[d+1][j-1][3] + E[j][0];
    for(i=1;i<=d;i++) {
        for(j=d+1;j<=N;j++) {
            int v = B[i][j][3] - B[i+1][j][3] - B[i][j-1][3] + B[i+1][j-1][3];
            if(v) ans.push_back({i, j});
        }
    }
    for(auto it : ans) r(it[0], it[1]);
}











Compilation message

treasure.cpp: In function 'int q(int, int, int, int)':
treasure.cpp:13:13: error: 'countTreasure' was not declared in this scope
   13 |     int v = countTreasure(a, b, c, d);
      |             ^~~~~~~~~~~~~
treasure.cpp: In function 'void r(int, int)':
treasure.cpp:18:5: error: 'Report' was not declared in this scope
   18 |     Report(a, b);
      |     ^~~~~~