#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
long long findGap(signed t,signed n)
{
if (t==2)
{
ll mn1,mx1;
MinMax(0,(ll)1e18,&mn1,&mx1);
ll st,mn,mx,ans=0;
for (int i=0;i<=60;i++)
{
MinMax(mn1+1,mn1+(1LL<<i),&mn,&mx);
if (mn!=-1)
{
ans=mn-mn1;
st=mx;
break;
}
}
while (st<mx1)
{
MinMax(st+1,st+ans,&mn,&mx);
if (mn!=-1)
st=mx;
else
{
int val=ans*2;
while (1)
{
MinMax(st+1,st+val,&mn,&mx);
if (mn!=-1)
{
ans=mn-st;
st=mx;
break;
}
}
}
}
return ans;
}
else
{
long long a[n],i=0,j=n-1,lim1=0,lim2=1e18;
long long mn,mx;
while (i<=j)
{
MinMax(lim1,lim2,&mn,&mx);
a[i++]=mn;
a[j--]=mx;
lim1=mn+1;
lim2=mx-1;
}
long long ans=0;
for (int i=0;i<n-1;i++)
ans=max(ans,a[i+1]-a[i]);
return ans;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:10: warning: 'st' may be used uninitialized in this function [-Wmaybe-uninitialized]
38 | ans=mn-st;
| ~~~^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
7 ms |
692 KB |
Output is correct |
17 |
Correct |
7 ms |
600 KB |
Output is correct |
18 |
Correct |
9 ms |
600 KB |
Output is correct |
19 |
Correct |
8 ms |
600 KB |
Output is correct |
20 |
Correct |
5 ms |
600 KB |
Output is correct |
21 |
Correct |
26 ms |
1972 KB |
Output is correct |
22 |
Correct |
27 ms |
1888 KB |
Output is correct |
23 |
Correct |
26 ms |
1880 KB |
Output is correct |
24 |
Correct |
27 ms |
1880 KB |
Output is correct |
25 |
Correct |
21 ms |
1880 KB |
Output is correct |
26 |
Correct |
25 ms |
1880 KB |
Output is correct |
27 |
Correct |
28 ms |
1880 KB |
Output is correct |
28 |
Correct |
25 ms |
1880 KB |
Output is correct |
29 |
Correct |
24 ms |
1880 KB |
Output is correct |
30 |
Correct |
20 ms |
1880 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
Partially correct |
2 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
3 |
Execution timed out |
3091 ms |
344 KB |
Time limit exceeded |
4 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
5 |
Partially correct |
0 ms |
344 KB |
Partially correct |
6 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
7 |
Execution timed out |
3094 ms |
344 KB |
Time limit exceeded |
8 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
9 |
Execution timed out |
3096 ms |
344 KB |
Time limit exceeded |
10 |
Execution timed out |
3048 ms |
344 KB |
Time limit exceeded |
11 |
Execution timed out |
3072 ms |
344 KB |
Time limit exceeded |
12 |
Execution timed out |
3047 ms |
344 KB |
Time limit exceeded |
13 |
Runtime error |
1 ms |
344 KB |
Execution failed because the return code was nonzero |
14 |
Execution timed out |
3047 ms |
344 KB |
Time limit exceeded |
15 |
Partially correct |
1 ms |
344 KB |
Partially correct |
16 |
Runtime error |
4 ms |
600 KB |
Execution failed because the return code was nonzero |
17 |
Runtime error |
3 ms |
600 KB |
Execution failed because the return code was nonzero |
18 |
Runtime error |
3 ms |
600 KB |
Execution failed because the return code was nonzero |
19 |
Runtime error |
5 ms |
592 KB |
Execution failed because the return code was nonzero |
20 |
Execution timed out |
3096 ms |
528 KB |
Time limit exceeded |
21 |
Execution timed out |
3025 ms |
1112 KB |
Time limit exceeded |
22 |
Execution timed out |
3039 ms |
1032 KB |
Time limit exceeded |
23 |
Execution timed out |
3058 ms |
1112 KB |
Time limit exceeded |
24 |
Runtime error |
16 ms |
1112 KB |
Execution failed because the return code was nonzero |
25 |
Partially correct |
46 ms |
1112 KB |
Partially correct |
26 |
Runtime error |
13 ms |
1112 KB |
Execution failed because the return code was nonzero |
27 |
Runtime error |
13 ms |
1032 KB |
Execution failed because the return code was nonzero |
28 |
Execution timed out |
3060 ms |
1112 KB |
Time limit exceeded |
29 |
Runtime error |
17 ms |
1112 KB |
Execution failed because the return code was nonzero |
30 |
Execution timed out |
3066 ms |
1112 KB |
Time limit exceeded |
31 |
Execution timed out |
3080 ms |
344 KB |
Time limit exceeded |
32 |
Correct |
0 ms |
344 KB |
Output is correct |