Submission #406186

#TimeUsernameProblemLanguageResultExecution timeMemory
406186shenxyA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
//#include "books.h"
#include <algorithm>
#include <vector>
using namespace std;
long long skim(int i){return i;}
void answer(vector<int> v){}
void impossible(){}
void solve(int N, int K, long long A, int S) {
	if (skim(1) > A) impossible();
	int l = 1, r = N;
	while (l != r) {
		if (skim((l + r) / 2 + 1) <= A) l = (l + r) / 2 + 1;
		else r = (l + r) / 2;
	}
	vector<long long> x, pos;
	if (r <= 2 * K) {
		for (int i = 1; i <= r; ++i) pos.push_back(i), x.push_back(skim(i));
	} else {
		for (int i = 1; i <= K; ++i) pos.push_back(i), x.push_back(skim(i));
		for (int i = r - K + 1; i <= r; ++i) pos.push_back(i), x.push_back(skim(i));
	}
	if (r != N && r >= K - 1) {
		long long sum = 0;
		for (int i = 0; i < K - 1; ++i) sum += x[i];
		sum += skim(r + 1);
		if (sum <= 2 * A) {
			vector<int> ans;
			for (int i = 1; i < K; ++i) ans.push_back(i);
			ans.push_back(r + 1);
			answer(ans);
		}
	}
	if (r < K) impossible();
	long long sum = 0;
	for (int i = 0; i < K; ++i) sum += x[i];
	if (sum > 2 * A) impossible();
	if (sum >= A) {
		vector<int> ans;
		for (int i = 1; i <= K; ++i) ans.push_back(i);
		answer(ans);
	}
	for (int i = K; i < x.size(); ++i) {
		sum += x[i] - x[i - K];
		if (sum >= A) {
			vector<int> ans;
			for (int j = i; j > i - K; --j) ans.push_back(j);
			answer(ans);
		}
	}
    impossible();
}

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for (int i = K; i < x.size(); ++i) {
      |                  ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccx5T4Ia.o: in function `answer(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0xa0): multiple definition of `answer(std::vector<int, std::allocator<int> >)'; /tmp/ccMcPDsd.o:books.cpp:(.text+0x10): first defined here
/usr/bin/ld: /tmp/ccx5T4Ia.o: in function `impossible()':
grader.cpp:(.text+0x160): multiple definition of `impossible()'; /tmp/ccMcPDsd.o:books.cpp:(.text+0x20): first defined here
/usr/bin/ld: /tmp/ccx5T4Ia.o: in function `skim(int)':
grader.cpp:(.text+0x1a0): multiple definition of `skim(int)'; /tmp/ccMcPDsd.o:books.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status