This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "gap.h"
#define MAXN 600007
using namespace std;
const long long inf=1e18;
long long *l,*r,*ll,*rr;
long long d,ans;
vector<long long> v;
long long findGap(int T, int N){
l=new long long();
r=new long long();
MinMax(1, inf, l,r);
if(T==1){
v.clear();
v.push_back(*l);
v.push_back(*r);
for(int i=1;i<=N;i++){
ll=new long long();
rr=new long long();
MinMax((*l)+1,(*r)-1,ll,rr);
if((*ll)==-1)break;
v.push_back(*ll);
v.push_back(*rr);
l=ll; r=rr;
if(*l==*r)break;
}
sort(v.begin(),v.end());
ans=1;
for(int i=0;i<v.size()-1;i++){
ans=max(ans,v[i+1]-v[i]);
}
return ans;
}
d=ans=(long long) (*r-*l)/(N-1);
while(*l!=*r){
while(true){
ll=new long long();
rr=new long long();
MinMax((*l)+1,(*l)+d+1,ll,rr);
if((*ll)!=-1)break;
d*=2;
}
ans=max(ans,*ll-*l);
d=ans;
l=rr;
}
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:45:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int i=0;i<v.size()-1;i++){
| ~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |