Submission #827817

# Submission time Handle Problem Language Result Execution time Memory
827817 2023-08-16T19:43:07 Z caganyanmaz Shortcut (IOI16_shortcut) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
#include "shortcut.h"
#define DEBUGGING

#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
using namespace std;

constexpr static int MXN = 1e6 + 5;
constexpr static int INF = 1e18;
int pf[MXN];
vector<int> d, l;
int c, n;

static inline int dist(int a, int b)
{
	return pf[max(a, b)] - pf[min(a, b)];
}

bool check(int k)
{
	int xl = -INF, xr = INF, yl = -INF, yr = INF;
	for (int i = 0; i < n; i++)
	{
		for (int j = i+1; j < n; j++)
		{
			if (dist(i, j) + d[i] + d[j] > k)
			{
				xl = max(xl, pf[j] + pf[i] - k + c + d[i] + d[j]);
				xr = min(xr, pf[j] + pf[i] + k - c - d[i] - d[j]);
				yl = max(yl, pf[j] - pf[i] - k + c + d[i] + d[j]);
				yr = min(yr, pf[j] - pf[i] + k - c - d[i] - d[j]);
			}
		}
	}
	if (xr < xl || yr < yl)
		return false;
	int j = 1;
	for (int i = 0; i < n; i++)
	{
		while (j < n && pf[i] + pf[j] < xl && pf[j] - pf[i] < yl) j++;
		if (j < n && pf[i] + pf[j] <= xr && pf[j] - pf[i] >= yl && pf[j] - pf[i] <= yr) return true;
	}

	return false;
}

long long find_shortcut(int32_t _n, vector<int32_t> _l, vector<int32_t> _d, int32_t _c)
{
	c = _c;
	n = _n;
	for (int i : _l)
		l.pb(i);
	for (int i : _d)
		d.pb(i);
	array<int, 3> v = {0, 0, 0};
	for (int i : d)
	{
		v[0] = i;
		sort(v.begin(), v.end());
	}
	for (int i = 1; i <= n; i++)
		pf[i] = pf[i-1] + l[i-1];
	//int ll = v[1] + v[2] + c - 1, rr = INF;
	int ll = 0, rr = INF;
	while (rr - ll > 1)
	{
		int m = ll+rr>>1;
		if (check(m))
			rr = m;
		else
			ll = m;
	}
	return rr;
}

Compilation message

shortcut.cpp:8:10: fatal error: ../debug.h: No such file or directory
    8 | #include "../debug.h"
      |          ^~~~~~~~~~~~
compilation terminated.