Submission #108200

# Submission time Handle Problem Language Result Execution time Memory
108200 2019-04-28T03:45:04 Z luciocf Gap (APIO16_gap) C++14
30 / 100
241 ms 1916 KB
#include <bits/stdc++.h>
#include "gap.h"

using namespace std;

const int maxn = 1e5+10;
const long long maxv = 1e18;

typedef long long ll;

ll a[maxn];

long long findGap(int T, int N)
{
	if (T == 1)
	{
		ll mn, mx;
		MinMax(0, maxv, &mn, &mx);

		int l = 1, r = N;
		a[1] = mn, a[N] = mx;

		while (true)
		{
			if (r-l <= 1) break;

			MinMax(a[l]+1, a[r]-1, &mn, &mx);

			a[++l] = mn, a[--r] = mx;
		}

		ll ans = 0;
		for (int i = 1; i < N; i++)
			ans = max(ans, a[i+1]-a[i]);

		return ans;
	}

	ll s = 0, mn, mx, last;
	ll ans = 0;

	MinMax(0, maxv, &mn, &mx);

	s = mn, last = mx;

	while (true)
	{
		mn = mx = -1;

		int ini = 0, fim = 60, k;
		while (ini <= fim)
		{
			int mid = (ini+fim)>>1;

			ll t = s+(1LL<<mid);

			MinMax(s+1, t, &mn, &mx);

			if (mn != -1 && mx != -1) k = mid, fim = mid-1;
			else ini = mid+1;
		}

		MinMax(s+1, s+(1LL<<k), &mn, &mx);

		ans = max(ans, mn-s);

		s = mx;
		if (s >= last) break;
	}

	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:63:21: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   MinMax(s+1, s+(1LL<<k), &mn, &mx);
                 ~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 16 ms 768 KB Output is correct
17 Correct 16 ms 768 KB Output is correct
18 Correct 16 ms 768 KB Output is correct
19 Correct 34 ms 760 KB Output is correct
20 Correct 14 ms 768 KB Output is correct
21 Correct 49 ms 1912 KB Output is correct
22 Correct 48 ms 1912 KB Output is correct
23 Correct 51 ms 1912 KB Output is correct
24 Correct 50 ms 1912 KB Output is correct
25 Correct 48 ms 1912 KB Output is correct
26 Correct 51 ms 1912 KB Output is correct
27 Correct 51 ms 1912 KB Output is correct
28 Correct 53 ms 1844 KB Output is correct
29 Correct 65 ms 1916 KB Output is correct
30 Correct 37 ms 1912 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 384 KB Partially correct
2 Partially correct 3 ms 256 KB Partially correct
3 Partially correct 3 ms 384 KB Partially correct
4 Partially correct 3 ms 384 KB Partially correct
5 Partially correct 2 ms 384 KB Partially correct
6 Partially correct 2 ms 384 KB Partially correct
7 Partially correct 2 ms 384 KB Partially correct
8 Partially correct 2 ms 384 KB Partially correct
9 Partially correct 2 ms 384 KB Partially correct
10 Partially correct 2 ms 384 KB Partially correct
11 Partially correct 4 ms 384 KB Partially correct
12 Partially correct 4 ms 384 KB Partially correct
13 Partially correct 4 ms 384 KB Partially correct
14 Partially correct 5 ms 384 KB Partially correct
15 Partially correct 5 ms 384 KB Partially correct
16 Partially correct 44 ms 512 KB Partially correct
17 Partially correct 41 ms 632 KB Partially correct
18 Partially correct 50 ms 608 KB Partially correct
19 Partially correct 40 ms 512 KB Partially correct
20 Partially correct 27 ms 512 KB Partially correct
21 Partially correct 139 ms 1196 KB Partially correct
22 Partially correct 148 ms 1144 KB Partially correct
23 Partially correct 145 ms 1084 KB Partially correct
24 Partially correct 170 ms 1272 KB Partially correct
25 Partially correct 241 ms 1144 KB Partially correct
26 Partially correct 164 ms 1152 KB Partially correct
27 Partially correct 150 ms 1272 KB Partially correct
28 Partially correct 149 ms 1312 KB Partially correct
29 Partially correct 139 ms 1144 KB Partially correct
30 Incorrect 102 ms 1272 KB Expected int32, but "3194474250" found
31 Partially correct 3 ms 384 KB Partially correct
32 Partially correct 3 ms 384 KB Partially correct