제출 #1333595

#제출 시각아이디문제언어결과실행 시간메모리
1333595gelastropodA Difficult(y) Choice (BOI21_books)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define int long long
#include "books.h"

using namespace std;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
//     books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ books_sample.cpp sample_grader.cpp
// in this folder.
//

vector<int> cache;

int qry(int n) {
    if (cache[n] != -1) return cache[n];
    return cache[n] = skim(n);
}

void solve(signed N, signed K, long long A, signed S) {
    cache.resize(N, -1);
    int low = 0, high = N - 1, ans = -1;
    while (low <= high) { // 17 queries
        int x = (low + high) / 2;
        if (qry(x) >= A) ans = x, low = x - 1;
        else high = x + 1;
    }
    for (int i = 0; i < K; i++) qry(i); // 20 queries
    for (int i = N - K; i < N; i++) qry(i);
    if (ans != -1 && qry(ans) <= 2 * A) {
        int crnts = qry(ans);
        for (int i = 0; i < K - 1; i++) crnts += qry(i);
        if (crnts <= 2 * A) {
            vector<int> res = { ans };
            for (int i = 0; i < K - 1; i++) res.push_back(i);
            answer(res);
            return;
        }
    }
    vector<int> funny;
    for (int i = K; i >= 0; i--) {
        int crnts = 0;
        for (int j = 0; j < i; j++) crnts += qry(j);
        for (int j = N - i; j < N; j++) crnts += qry(j);
        funny.push_back(crnts);
    }
    if (funny[0] > 2 * A || funny.back() < A) {
        impossible();
        return;
    }
    if (funny[0] >= A) {
        vector<int> res;
        for (int i = 0; i < K; i++) res.push_back(i);
        answer(res);
        return;
    }
    int idx = lower_bound(funny.begin(), funny.end(), A) - funny.begin();
    low = K - idx, high = N - idx, ans = -1;
    while (low <= high) { // 17 queries
        int x = (low + high) / 2;
        if (funny[idx - 1] - qry(low) + qry(x) >= A) ans = x, low = x - 1;
        else high = x + 1;
    }
    vector<int> res = { ans };
    for (int i = 0; i < K - idx; i++) res.push_back(i);
    for (int i = N - idx + 1; i < N; i++) res.push_back(i);
    answer(res);
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccilF6Qc.o: in function `qry(long long)':
books.cpp:(.text+0x25): undefined reference to `skim(long long)'
/usr/bin/ld: /tmp/ccilF6Qc.o: in function `solve(int, int, long long, int)':
books.cpp:(.text+0x145): undefined reference to `skim(long long)'
/usr/bin/ld: books.cpp:(.text+0x161): undefined reference to `skim(long long)'
/usr/bin/ld: books.cpp:(.text+0x17c): undefined reference to `skim(long long)'
/usr/bin/ld: books.cpp:(.text+0x20e): undefined reference to `skim(long long)'
/usr/bin/ld: /tmp/ccilF6Qc.o:books.cpp:(.text+0x26e): more undefined references to `skim(long long)' follow
/usr/bin/ld: /tmp/ccilF6Qc.o: in function `solve(int, int, long long, int)':
books.cpp:(.text+0x44c): undefined reference to `answer(std::vector<long long, std::allocator<long long> >)'
/usr/bin/ld: books.cpp:(.text+0x603): undefined reference to `skim(long long)'
/usr/bin/ld: books.cpp:(.text+0x6fa): undefined reference to `answer(std::vector<long long, std::allocator<long long> >)'
/usr/bin/ld: books.cpp:(.text+0xb3c): undefined reference to `answer(std::vector<long long, std::allocator<long long> >)'
/usr/bin/ld: books.cpp:(.text+0xb9d): undefined reference to `skim(long long)'
/usr/bin/ld: books.cpp:(.text+0xbb2): undefined reference to `skim(long long)'
/usr/bin/ld: books.cpp:(.text+0xc57): undefined reference to `skim(long long)'
/usr/bin/ld: books.cpp:(.text+0xc85): undefined reference to `skim(long long)'
/usr/bin/ld: books.cpp:(.text+0xfee): undefined reference to `answer(std::vector<long long, std::allocator<long long> >)'
/usr/bin/ld: books.cpp:(.text+0x1155): undefined reference to `answer(std::vector<long long, std::allocator<long long> >)'
/usr/bin/ld: books.cpp:(.text+0x136a): undefined reference to `answer(std::vector<long long, std::allocator<long long> >)'
/usr/bin/ld: books.cpp:(.text+0x141c): undefined reference to `answer(std::vector<long long, std::allocator<long long> >)'
collect2: error: ld returned 1 exit status