# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
108203 |
2019-04-28T03:50:00 Z |
luciocf |
Gap (APIO16_gap) |
C++14 |
|
202 ms |
1956 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;
ll ini = 0, fim = 60, k;
while (ini <= fim)
{
ll 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 |
256 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 |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 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 |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
408 KB |
Output is correct |
16 |
Correct |
14 ms |
768 KB |
Output is correct |
17 |
Correct |
13 ms |
768 KB |
Output is correct |
18 |
Correct |
13 ms |
772 KB |
Output is correct |
19 |
Correct |
14 ms |
768 KB |
Output is correct |
20 |
Correct |
12 ms |
768 KB |
Output is correct |
21 |
Correct |
51 ms |
1956 KB |
Output is correct |
22 |
Correct |
49 ms |
1912 KB |
Output is correct |
23 |
Correct |
69 ms |
1912 KB |
Output is correct |
24 |
Correct |
55 ms |
1912 KB |
Output is correct |
25 |
Correct |
51 ms |
1908 KB |
Output is correct |
26 |
Correct |
48 ms |
1912 KB |
Output is correct |
27 |
Correct |
49 ms |
1912 KB |
Output is correct |
28 |
Correct |
50 ms |
1884 KB |
Output is correct |
29 |
Correct |
57 ms |
1912 KB |
Output is correct |
30 |
Correct |
39 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 |
2 ms |
384 KB |
Partially correct |
2 |
Partially correct |
2 ms |
356 KB |
Partially correct |
3 |
Partially correct |
2 ms |
384 KB |
Partially correct |
4 |
Partially correct |
3 ms |
384 KB |
Partially correct |
5 |
Partially correct |
3 ms |
384 KB |
Partially correct |
6 |
Partially correct |
3 ms |
384 KB |
Partially correct |
7 |
Partially correct |
0 ms |
380 KB |
Partially correct |
8 |
Partially correct |
2 ms |
384 KB |
Partially correct |
9 |
Partially correct |
3 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 |
4 ms |
384 KB |
Partially correct |
15 |
Partially correct |
5 ms |
384 KB |
Partially correct |
16 |
Partially correct |
41 ms |
512 KB |
Partially correct |
17 |
Partially correct |
37 ms |
512 KB |
Partially correct |
18 |
Partially correct |
38 ms |
576 KB |
Partially correct |
19 |
Partially correct |
36 ms |
512 KB |
Partially correct |
20 |
Partially correct |
23 ms |
616 KB |
Partially correct |
21 |
Partially correct |
157 ms |
1144 KB |
Partially correct |
22 |
Partially correct |
156 ms |
1144 KB |
Partially correct |
23 |
Partially correct |
133 ms |
1168 KB |
Partially correct |
24 |
Partially correct |
139 ms |
1160 KB |
Partially correct |
25 |
Partially correct |
202 ms |
1152 KB |
Partially correct |
26 |
Partially correct |
154 ms |
1144 KB |
Partially correct |
27 |
Partially correct |
154 ms |
1192 KB |
Partially correct |
28 |
Partially correct |
144 ms |
1144 KB |
Partially correct |
29 |
Partially correct |
152 ms |
1272 KB |
Partially correct |
30 |
Incorrect |
94 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 |