Submission #1144319

#TimeUsernameProblemLanguageResultExecution timeMemory
1144319THXuanGap (APIO16_gap)C++20
Compilation error
0 ms0 KiB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long findGap(int T, int N)
{
	if (T == 1) {
		ll l = 0, r = 1e18;
		vector<ll>a;
		while (a.size() < N) {
			ll mn, mx;
			MinMax(l, r, &mn, &mx);
			a.push_back(mn);
			if (mn == mx)break;
			a.push_back(mx);
			l = mn + 1;
			r = mx - 1;
			if (a.size() == N)break;
		}
		ll ans = 0;
		sort(a.begin(), a.end());
		for (int i = 0; i + 1 < N; i++)ans = max(ans, a[i + 1] - a[i]);
		return ans;
	}
	else {
		ll mn = 0, mx = 0;
		MinMax(1, r, &mn, &mx);
		ll step = (mx - mn + N - 2) / (N - 1);
		ll ans = step, x, y, l = mn, i;
		for (i = mn; i + step < mx; i += step + 1) {
			MinMax(i, i + step, &x, &y);
			if (x != -1) {
				ans = max(ans, x - l);
				l = y;
			}
		}
		MinMax(i, mx, &x, &y);
		if (x != -1) ans = max(ans, x - l);
		return ans;
	}
}

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:27: error: 'r' was not declared in this scope
   27 |                 MinMax(1, r, &mn, &mx);
      |                           ^