# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
38771 |
2018-01-06T13:00:17 Z |
oTTo_22 |
Gap (APIO16_gap) |
C++14 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "gap.h"
#define se second
#define fi first
using namespace std;
long long ans;
long double bb;
void func (long long L,long long R)
{
long long mi1,ma1,mi2,ma2;
long long mid=(L+R)/2;
MinMax(L,mid,&mi1,&ma1);
MinMax(mid,R,&mi2,&ma2);
if (ma1==-1 && mi2==-1) {
ans=max(ans,R-L);
return;
}
if (ma1==-1) {
ans=max(ans,mi2-L);
return;
}
if (mi2==-1) {
ans=max(ans,R-ma1);
return;
}
if (ma1==L && mi2==R){
ans=max(ans,R-L);
return;
}
if (R-L==1){
ans=max(ans,R-L);
return;
}
if (ma1-L>ans && ma1-L>=bb)
func(L,ma1);
if (R-mi2>ans && R-mi2>=bb)
func(mi2,R);
if (mi2-ma1>ans && mi2-ma1>=bb)
func (ma1,mi2);
}
long long findGap(int T, int N)
{
long long m=(long long)N;
long long Mn,Mx;
long long S=0;
long long TT=1000000000000000000;
MinMax(S,TT,&Mn,&Mx);
if (m==2)
return Mx-Mn;
bb=((Mx-Mn)*1.0)/((m-1)*1.0);
ans=0;
if (T==2) {
func (Mn,Mx);
return ans;
}
else {
for (int i=1;i<(N+1)/2;i++){
long long mmn, mmx;
MinMax(mn+1,mx-1,&mmn,&mmx);
ans=max(ans,mmn-mn);
ans=max(ans,mx-mmx);
mn=mmn;
mx=mmx;
}
ans=max(ans,mx-mn);
return ans;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:62:11: error: 'mn' was not declared in this scope
MinMax(mn+1,mx-1,&mmn,&mmx);
^
gap.cpp:62:16: error: 'mx' was not declared in this scope
MinMax(mn+1,mx-1,&mmn,&mmx);
^
gap.cpp:68:15: error: 'mx' was not declared in this scope
ans=max(ans,mx-mn);
^
gap.cpp:68:18: error: 'mn' was not declared in this scope
ans=max(ans,mx-mn);
^