Submission #406903

#TimeUsernameProblemLanguageResultExecution timeMemory
406903SeDunionGap (APIO16_gap)C++17
0 / 100
30 ms1952 KiB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve1(int N) {
	ll L = -1, R = ll(1e18)+1;
	vector<ll>a(N);
	int l = 0, r = N - 1;
	while (l <= r) {
		ll *lq, *rq;
		MinMax(L+1, R-1, lq, rq);
		L = *lq, R = *rq;
		a[l++] = L, a[r--] = R;
	}
	ll answer = 0;
	for (int i = 0 ; i < N - 1 ; ++ i) answer = max(answer, a[i + 1] - a[i]);
	return answer;
}

ll solve2(int N) {
	return -1;
}

ll findGap(int T, int N) {
	if (T == 1) {
		return solve1(N);
	} else {
		return solve2(N);
	}
}

Compilation message (stderr)

gap.cpp: In function 'll solve1(int)':
gap.cpp:12:9: warning: 'lq' may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 |   MinMax(L+1, R-1, lq, rq);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~
gap.cpp:12:9: warning: 'rq' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...