Submission #1091861

# Submission time Handle Problem Language Result Execution time Memory
1091861 2024-09-22T11:20:27 Z lovrot Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#include "gap.h"
#include <cstdio>
#include <algorithm>

#define X first
#define Y second
#define PB push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)

using namespace std; 

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll OO = 1e18;

int cnt = 0;

pll query(ll a, ll b) { 
	if(a > b) { return {-1, -1}; }
	ll ret, ret_;
	++cnt;
	MinMax(a, b, &ret, &ret_);
	return {ret, ret_};
}

ll solve(ll lst, ll l, ll r, int n) { 
	if(n == 1) { return 0; }
	pll res = query(l, l + (r - l) / (n - 1)); 
	return max(res.X - lst, solve(max(lst, res.Y), l + (r - l) / (n - 1) + 1, r, n - 1));
}

ll findGap(int T, int n) {
	if(T == 1) { 
		int minp = 0;
		int maxp = n - 1;
		ll mn = 0, minr;
		ll mx = INF, maxr;
	 
		while(minp <= maxp){ 
			MinMax(mn, mx, &minr, &maxr);
			niz[minp] = minr;
			niz[maxp] = maxr;
			mn = minr + 1;
			mx = maxr - 1; 
			minp++;
			maxp--;
		}
	 
		ll ans = 0;
		for(int i = 0; i < n - 1; i++) ans = max(ans, niz[i + 1] - niz[i]);
		return ans; cnt = 0;
	}
	pll res = query(0, OO);
	ll ret = solve(res.X, res.X + 1, res.Y, n);
	return ret;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:39:11: error: 'INF' was not declared in this scope
   39 |   ll mx = INF, maxr;
      |           ^~~
gap.cpp:42:27: error: 'maxr' was not declared in this scope; did you mean 'maxp'?
   42 |    MinMax(mn, mx, &minr, &maxr);
      |                           ^~~~
      |                           maxp
gap.cpp:43:4: error: 'niz' was not declared in this scope
   43 |    niz[minp] = minr;
      |    ^~~
gap.cpp:52:49: error: 'niz' was not declared in this scope
   52 |   for(int i = 0; i < n - 1; i++) ans = max(ans, niz[i + 1] - niz[i]);
      |                                                 ^~~