#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
long long x[100009];
const long long xmax = 1e18;
long long rand15 () {return rand () & 32767;}
long long rand30 () {return (rand15 () << 15LL) | rand15 ();}
long long rand60 () {return (rand30 () << 30LL) | rand30 ();}
vector < long long > divide (long long a, long long b)
{
if (a > b) return {};
long long mid = a + rand60 () % (b - a);
long long x, y, z, t;
MinMax (a, mid, &x, &y);
MinMax (mid + 1, b, &z, &t);
vector < long long > ans;
if (x == -1) ;
else
{
ans.push_back (x);
if (x != y)
{
vector < long long > curr;
curr = divide (x + 1, y - 1);
for (auto it : curr)
ans.push_back (it);
curr.clear ();
ans.push_back (y);
}
}
if (z == -1) ;
else
{
ans.push_back (z);
if (z != t)
{
vector < long long > curr;
curr = divide (z + 1, t - 1);
for (auto it : curr)
ans.push_back (it);
curr.clear ();
ans.push_back (t);
}
}
return ans;
}
long long findGap(int T, int N)
{
srand (time (0));
if (T == 1)
{
long long a = 0, b = xmax;
for (int i = 1, j = N; i<=j; i ++, j --)
MinMax (a, b, &x[i], &x[j]), a = x[i] + 1, b = x[j] - 1;
long long ans = x[2] - x[1];
for (int i=1; i<N; i++)
if (x[i + 1] - x[i] > ans)
ans = x[i + 1] - x[i];
return ans;
}
vector < long long > v = divide (0, xmax);
long long ans = v[1] - v[0];
for (int i=0; i<v.size () - 1; i++)
ans = max (ans, v[i + 1] - v[i]);
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:68:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<v.size () - 1; i++)
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5928 KB |
Output is correct |
2 |
Correct |
0 ms |
5928 KB |
Output is correct |
3 |
Correct |
0 ms |
5928 KB |
Output is correct |
4 |
Correct |
0 ms |
5928 KB |
Output is correct |
5 |
Correct |
0 ms |
5928 KB |
Output is correct |
6 |
Correct |
0 ms |
5928 KB |
Output is correct |
7 |
Correct |
0 ms |
5928 KB |
Output is correct |
8 |
Correct |
0 ms |
5928 KB |
Output is correct |
9 |
Correct |
0 ms |
5928 KB |
Output is correct |
10 |
Correct |
0 ms |
5928 KB |
Output is correct |
11 |
Correct |
1 ms |
5928 KB |
Output is correct |
12 |
Correct |
1 ms |
5928 KB |
Output is correct |
13 |
Correct |
1 ms |
5928 KB |
Output is correct |
14 |
Correct |
1 ms |
5928 KB |
Output is correct |
15 |
Correct |
1 ms |
5928 KB |
Output is correct |
16 |
Correct |
15 ms |
5928 KB |
Output is correct |
17 |
Correct |
15 ms |
5928 KB |
Output is correct |
18 |
Correct |
14 ms |
5928 KB |
Output is correct |
19 |
Correct |
19 ms |
5928 KB |
Output is correct |
20 |
Correct |
10 ms |
5928 KB |
Output is correct |
21 |
Correct |
55 ms |
5928 KB |
Output is correct |
22 |
Correct |
49 ms |
5928 KB |
Output is correct |
23 |
Correct |
58 ms |
5928 KB |
Output is correct |
24 |
Correct |
60 ms |
5928 KB |
Output is correct |
25 |
Correct |
52 ms |
5928 KB |
Output is correct |
26 |
Correct |
48 ms |
5928 KB |
Output is correct |
27 |
Correct |
50 ms |
5928 KB |
Output is correct |
28 |
Correct |
41 ms |
5928 KB |
Output is correct |
29 |
Correct |
55 ms |
5928 KB |
Output is correct |
30 |
Correct |
43 ms |
5928 KB |
Output is correct |
31 |
Correct |
0 ms |
5928 KB |
Output is correct |
32 |
Correct |
0 ms |
5928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5928 KB |
Output is correct |
2 |
Correct |
0 ms |
5928 KB |
Output is correct |
3 |
Correct |
0 ms |
5928 KB |
Output is correct |
4 |
Correct |
0 ms |
5928 KB |
Output is correct |
5 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
6 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
7 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
8 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
9 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
10 |
Runtime error |
0 ms |
5928 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
11 |
Partially correct |
2 ms |
5928 KB |
Partially correct |
12 |
Partially correct |
2 ms |
5928 KB |
Partially correct |
13 |
Partially correct |
2 ms |
6064 KB |
Partially correct |
14 |
Partially correct |
1 ms |
6068 KB |
Partially correct |
15 |
Partially correct |
2 ms |
6060 KB |
Partially correct |
16 |
Partially correct |
27 ms |
6784 KB |
Partially correct |
17 |
Partially correct |
26 ms |
6784 KB |
Partially correct |
18 |
Partially correct |
17 ms |
6784 KB |
Partially correct |
19 |
Partially correct |
26 ms |
6784 KB |
Partially correct |
20 |
Runtime error |
6 ms |
5928 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
21 |
Partially correct |
91 ms |
9088 KB |
Partially correct |
22 |
Partially correct |
100 ms |
9088 KB |
Partially correct |
23 |
Partially correct |
92 ms |
9088 KB |
Partially correct |
24 |
Partially correct |
102 ms |
9088 KB |
Partially correct |
25 |
Partially correct |
91 ms |
9088 KB |
Partially correct |
26 |
Partially correct |
96 ms |
9152 KB |
Partially correct |
27 |
Partially correct |
90 ms |
9280 KB |
Partially correct |
28 |
Partially correct |
105 ms |
9152 KB |
Partially correct |
29 |
Partially correct |
96 ms |
9088 KB |
Partially correct |
30 |
Runtime error |
16 ms |
5928 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
31 |
Runtime error |
0 ms |
5928 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
32 |
Runtime error |
0 ms |
5928 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |