Submission #967909

# Submission time Handle Problem Language Result Execution time Memory
967909 2024-04-23T05:05:01 Z TAhmed33 Gap (APIO16_gap) C++
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("trapv")
#include "gap.h"
#include "grader.cpp"
using namespace std;
typedef long long ll;
const ll inf = 1e18;
pair <ll, ll> ask (ll l, ll r) {
	if (l > r) return {-1, -1};
	ll mn = l, mx = r;
	MinMax(l, r, &mn, &mx);
	return {mn, mx};
}
ll findGap (int t, int n) {
	if (t == 1) {
		auto g = ask(0, inf); n -= 2;
		if (!n) {
			return g.second - g.first;
		}
		ll ans = 0;
		while (n >= 1) {
			auto h = ask(g.first + 1, g.second - 1);
			if (h.first == -1) {
				ans = max(ans, g.second - g.first);
				break;
			}
			assert(g.first < h.first && h.first <= h.second && h.second < g.second);
			ans = max(ans, g.second - h.second);
			ans = max(ans, h.first - g.first);
			g = h;
			n -= 2;
		}
		return ans;
	}
	auto g = ask(0, inf);
	ll L = g.second - g.first + 1;
	ll x = (L + n - 2) / (n - 1);
	ll ans = x;
	vector <pair <ll, ll>> dd;
	for (ll i = g.first; i + x <= g.second; i += x + 1) {
		auto h = ask(i, min(g.second, i + x));
		if (h.first != -1) dd.push_back(h);
	}
	for (int i = 1; i < (int)dd.size(); i++) ans = max(ans, dd[i].first - dd[i - 1].second);
	return ans;
}

Compilation message

/usr/bin/ld: /tmp/cc7w8Huj.o: in function `MinMax(long long, long long, long long*, long long*)':
grader.cpp:(.text+0x0): multiple definition of `MinMax(long long, long long, long long*, long long*)'; /tmp/ccufIaji.o:gap.cpp:(.text+0x300): first defined here
/usr/bin/ld: /tmp/cc7w8Huj.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccufIaji.o:gap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status