Submission #521394

# Submission time Handle Problem Language Result Execution time Memory
521394 2022-02-02T04:05:40 Z pavement Hidden Sequence (info1cup18_hidden) C++17
Compilation error
0 ms 0 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll pf[100005];
map<int, ll> mem;

ll qry(int x) {
	if (mem.find(x) != mem.end()) return mem[x];
	return mem[x] = skim(x);
}

void solve(int N, int K, ll A, int S) {
	int lo = 1, hi = N, ans = -1;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (qry(mid) >= A) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	if (ans != -1 && ans < K) impossible();
	if (ans != -1) {
		ll cum = qry(ans);
		vector<int> vec;
		for (int i = 1; i < K; i++) cum += qry(i);
		if (A <= cum && cum <= 2 * A) {
			for (int i = 1; i < K; i++) vec.push_back(i);
			vec.push_back(ans);
			answer(vec);
			return;
		} else N = ans - 1;
	}
	ll cum = 0;
	vector<int> vec;
	for (int i = 1; i <= K; i++) pf[i] = pf[i - 1] + qry(i);
	if (A <= pf[K] && pf[K] <= 2 * A) {
		for (int i = 1; i <= K; i++) vec.push_back(i);
		answer(vec);
		return;
	}
	for (int i = N; i >= N - K + 1; i--) {
		cum += qry(i);
		vec.push_back(i);
		if (A <= pf[K - (N - i + 1)] + cum && pf[K - (N - i + 1)] + cum <= 2 * A) {
			for (int j = 1; j <= K - (N - i + 1); j++) vec.push_back(j);
			answer(vec);
			return;
		}
	}
	impossible();
}

Compilation message

hidden.cpp:1:10: fatal error: books.h: No such file or directory
    1 | #include "books.h"
      |          ^~~~~~~~~
compilation terminated.
grader.cpp: In function 'int main()':
grader.cpp:28:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   28 |     fprintf (fifo_out, "%d\n", ans.size ());
      |                         ~^     ~~~~~~~~~~~
      |                          |              |
      |                          int            std::vector<int>::size_type {aka long unsigned int}
      |                         %ld
grader.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i=0; i<ans.size () && i < N; i++)
      |                   ~^~~~~~~~~~~~