답안 #976118

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976118 2024-05-06T07:52:56 Z Circling A Difficult(y) Choice (BOI21_books) C++17
컴파일 오류
0 ms 0 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#include "books.h"
using namespace std;

int64_t arr[100001];


int64_t wiseskim(int i){
    if (arr[i] == -1) arr[i] = skim(i);
    return arr[i];
}


void solve(int n, int k, int64_t a, int s){
    for (int i = 1; i <= n; i++) arr[i] = -1;
    vector<int> solution;
    if (k * wiseskim(1) + k * (k - 1) / 2 > 2 * a){
        impossible();
        return;
    }
    int lastbelowa = 0;
    for (int i = 16; i >= 0; i--) if (lastbelowa + (1 << i) <= n && wiseskim(lastbelowa + (1 << i)) < a) lastbelowa += 1 << i;
    if (lastbelowa < k){
        impossible();
        return;
    }
    int64_t sum;
    if (lastbelowa < n){
        sum = wiseskim(lastbelowa + 1);
        for (int i = 1; i < k; i++) sum += wiseskim(i);
        if (sum <= 2 * a){
            for (int i = 1; i < k; i++) solution.push_back(i);
            solution.push_back(lastbelowa + 1);
            answer(solution);
            return;
        }
    }
    sum = 0;
    solution.clear();
    for (int i = 1; i <= k; i++){
        solution.push_back(i);
        sum += wiseskim(i);
    }
    if (sum > 2 * a){
        impossible();
        return;
    }
    if (sum >= a){
        answer(solution);
        return;
    }
    for (int i = 1; i <= k; i++){
        sum += wiseskim(lastbelowa + 1 - i) - wiseskim(k + 1 - i);
        solution[k - i] = lastbelowa + 1 - i;
        if (sum >= a){
            answer(solution);
            return;
        }
    }
    impossible();
}

Compilation message

/usr/bin/ld: /tmp/cca45cEd.o: in function `main':
grader.cpp:(.text.startup+0x83): undefined reference to `solve(int, int, long long, int)'
collect2: error: ld returned 1 exit status