Submission #553099

#TimeUsernameProblemLanguageResultExecution timeMemory
553099Vladth11A Difficult(y) Choice (BOI21_books)C++14
Compilation error
0 ms0 KiB
#include "books.h"
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long double, pii> muchie;

const ll NMAX = 1000001;
const ll VMAX = 1001;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 447;
const ll base = 31;
const ll nr_of_bits = 21;

map <int, ll> mp;

ll afla(int i) {
    if(mp.find(i) != mp.end())
        return mp[i];
    return mp[i] = skim(i);
}

void solve(int N, int K, long long A, int S) {
    ll sum = 0;
    vector <int> first;
    for(int i = 1; i <= K; i++) {
        ll acum = afla(i);
        first.push_back(i);
        sum += acum;
    }
    if(sum > 2 * A) {
        impossible();
        return;
    }
    if(sum >= A && sum <= 2 * A) {
        answer(first);
        return;
    }
    reverse(first.begin(), first.end()); /// eliminam pe cel mai mic
    int r = 0, pas = (1 << nr_of_bits);
    while(pas) {
        if(r + pas <= N) {
            ll acum = afla(r + pas);
            if(acum <= A) {
                r += pas;
            }
        }
        pas /= 2;
    }
    vector <int> second;
    if(r < N)
        r++;
    if(r < K)
        return;
    ll sum = 0;
    for(i = r; i >= r - K + 1; r--) {
        second.push_back(i);
        sum += afla(i);
    }
    if(sum >= A && sum <= 2 * A) {
        answer(second);
        return;
    }
    for(i = r - 1; i >= r - K + 1; r--) {
        swap(second[r - i], first[(r - i) - 1]);
        sum += afla(first[(r - i) - 1]);
        sum -= afla(second[r - i]);
        if(sum >= A && sum <= 2 * A) {
            answer(second);
            return;
        }
    }
    impossible();
}

Compilation message (stderr)

books.cpp:18:1: error: 'map' does not name a type
   18 | map <int, ll> mp;
      | ^~~
books.cpp: In function 'll afla(int)':
books.cpp:21:8: error: 'mp' was not declared in this scope
   21 |     if(mp.find(i) != mp.end())
      |        ^~
books.cpp:23:12: error: 'mp' was not declared in this scope
   23 |     return mp[i] = skim(i);
      |            ^~
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:42:5: error: 'reverse' was not declared in this scope
   42 |     reverse(first.begin(), first.end()); /// eliminam pe cel mai mic
      |     ^~~~~~~
books.cpp:58:8: error: redeclaration of 'll sum'
   58 |     ll sum = 0;
      |        ^~~
books.cpp:27:8: note: 'll sum' previously declared here
   27 |     ll sum = 0;
      |        ^~~
books.cpp:59:9: error: 'i' was not declared in this scope
   59 |     for(i = r; i >= r - K + 1; r--) {
      |         ^
books.cpp:67:9: error: 'i' was not declared in this scope
   67 |     for(i = r - 1; i >= r - K + 1; r--) {
      |         ^