Submission #1201660

#TimeUsernameProblemLanguageResultExecution timeMemory
1201660IBoryA Difficult(y) Choice (BOI21_books)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "books.h"
typedef long long ll;
using namespace std;

const int MAX = 100007;
ll X[MAX];

ll Skim(int p) {
	if (X[p]) return X[p];
	return X[p] = skim(p);
}

void solve(int N, int K, ll A, int S) {
	memset(X, 0, 8 * (N + 1));

	unsigned ll base = 0;
	for (int i = 1; i < K; ++i) base += Skim(i);

	int L = K, R = N + 1;
	while (L + 1 < R) {
		int mid = (L + R) >> 1;
		(A * 2 < base + Skim(mid) ? R : L) = mid;
	}

	vector<int> ans(K);
	iota(ans.begin(), ans.end(), 1);
	if (A * 2 < base + Skim(L)) impossible();
	if (A <= base + skim(L)) {
		ans[K - 1] = L;
		answer(ans);
		return;
	}

	base += Skim(K);
	for (int i = K; i > 0; --i) {
		int r = L - (K - i);
		base += Skim(r) - Skim(i);
		ans[i - 1] = r;
		if (A <= base && base <= A * 2) {
			answer(ans);
			return;
		}
	}
}

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:17:21: error: expected initializer before 'base'
   17 |         unsigned ll base = 0;
      |                     ^~~~
books.cpp:18:37: error: 'base' was not declared in this scope
   18 |         for (int i = 1; i < K; ++i) base += Skim(i);
      |                                     ^~~~
books.cpp:23:26: error: 'base' was not declared in this scope
   23 |                 (A * 2 < base + Skim(mid) ? R : L) = mid;
      |                          ^~~~
books.cpp:28:21: error: 'base' was not declared in this scope
   28 |         if (A * 2 < base + Skim(L)) impossible();
      |                     ^~~~
books.cpp:29:18: error: 'base' was not declared in this scope
   29 |         if (A <= base + skim(L)) {
      |                  ^~~~
books.cpp:35:9: error: 'base' was not declared in this scope
   35 |         base += Skim(K);
      |         ^~~~