답안 #142505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
142505 2019-08-09T10:42:16 Z popovicirobert Meandian (CEOI06_meandian) C++14
컴파일 오류
0 ms 0 KB
/*
  CEOI 2006
  Competition Day #2
  Task MEANDIAN
  Sample library for C/C++
*/

/*
  input file format:
  N
  a1 a2 ... aN
*/

#include <bits/stdc++.h>
#include "libeman.h"

using namespace std;

const int INF = 1e9;
const int MAXN = 100;
int sol[MAXN];

inline int get(vector <int> a) {
    bool ok = 1;
    int i;
    for(i = 1; ok; i++) {
        ok = 0;
        for(auto it : a) {
            if(it == i) {
                ok = 1;
            }
        }
    }
    return i - 1;
}

int main() {
    int n, i, j;
    n = Init();

    vector <int> a = {1, 2, 3, 4};
    vector <int> b = a;
    int mn = Meandian(a[0], a[1], a[2], a[3]);
    int mx = mn;
    for(i = 5; i <= n; i++) {
        vector <int> aux = a;
        for(j = 0; j < 4; j++) {
            vector <int> cur;
            for(int k = 0; k < 4; k++) {
                cur.push_back((k != j ? a[k] : i));
            }
            int val = Meandian(cur[0], cur[1], cur[2], cur[3]);
            if(val < mn) {
                mn = val, aux = cur;
            }
        }
        a = aux;

        aux = b;
        for(j = 0; j < 4; j++) {
            vector <int> cur;
            for(int k = 0; k < 4; k++) {
                cur.push_back((k != j ? b[k] : i));
            }
            int val = Meandian(cur[0], cur[1], cur[2], cur[3]);
            if(val > mx) {
                mx = val, aux = cur;
            }
        }
        b = aux;
    }

    memset(sol, -1, sizeof(sol));
    if(n <= 6) { Solution(sol); return 0; }

    vector <bool> vis(n + 1, 1);
    for(auto it : a) {
        vis[it] = 0;
    }
    for(auto it : b) {
        vis[it] = 0;
    }

    int id_mn4, ga = get(a);
    mn = INF;
    for(i = 0; i < 4; i++) {
        vector <int> cur;
        for(j = 0; j < 4; j++) {
            cur.push_back((i != j ? a[j] : ga));
        }
        int val = Meandian(cur[0], cur[1], cur[2], cur[3]);
        if(val < mn) {
            mn = val, id_mn4 = a[i];
        }
    }
    vis[id_mn4] = 1;
    vector <int> aux;
    for(auto it : a) {
        if(it != id_mn4) {
            aux.push_back(it);
        }
    }
    a = aux;

    int id_mx4, gb = get(b);
    mx = 0;
    for(i = 0; i < 4; i++) {
        vector <int> cur;
        for(j = 0; j < 4; j++) {
            cur.push_back((i != j ? b[j] : gb));
        }
        int val = Meandian(cur[0], cur[1], cur[2], cur[3]);
        if(val > mx) {
            mx = val, id_mx4 = b[i];
        }
    }
    vis[id_mx4] = 1;
    aux.clear();
    for(auto it : b) {
        if(it != id_mx4) {
            aux.push_back(it);
        }
    }
    b = aux;

    int id_mn3; mn = INF;
    for(i = 0; i < 3; i++) {
        for(j = i + 1; j < 3; j++) {
            int val = Meandian(a[i], a[j], ga, id_mn4);
            if(val < mn) {
                mn = val, id_mn3 = a[3 - i - j];
            }
        }
    }
    vis[id_mn3] = 1;

    int id_mx3; mx = 0;
    for(i = 0; i < 3; i++) {
        for(j = i + 1; j < 3; j++) {
            int val = Meandian(b[i], b[j], gb, id_mx4);
            if(val > mx) {
                mx = val, id_mx3 = b[3 - i - j];
            }
        }
    }
    vis[id_mx3] = 1;

    int ida = (id_mn3 == a[0] ? a[1] : a[0]);
    int idb = (id_mx3 == b[0] ? b[1] : b[0]);
    vector <int> ids;
    for(i = 1; i <= n; i++) {
        if(vis[i]) ids.push_back(i);
    }

    int x = 2 * Meandian(ida, idb, ids[0], ids[1]);
    int y = 2 * Meandian(ida, idb, ids[0], ids[2]);
    int z = 2 * Meandian(ida, idb, ids[1], ids[2]);

    sol[ids[0] - 1] = (x + y - z) / 2;
    sol[ids[1] - 1] = (x + z - y) / 2;
    sol[ids[2] - 1] = (y + z - x) / 2;
    for(i = 3; i < ids.size(); i++) {
        sol[ids[i] - 1] = 2 * Meandian(ida, idb, ids[i - 1], ids[i]) - sol[ids[i - 1] - 1];
    }

    Solution(sol);

    return 0;
}

Compilation message

meandian.cpp:16:10: fatal error: libeman.h: No such file or directory
 #include "libeman.h"
          ^~~~~~~~~~~
compilation terminated.