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>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#include "gap.h"
typedef pair<ll,ll> pll;
const ll inf=1e18+99;
int n;
ll P(ll x,ll y){
return (x+y-1)/y;
}
pair<ll,ll> get(ll l,ll r){
ll mn,mx;
MinMax(l,r,&mn,&mx);
return {mn,mx};
}
ll findGap(int T, int _n){
n=_n;
if(T==1){
vector<ll> A;
pll last=get(0,inf);
A.pb(last.F);
A.pb(last.S);
f(i,0,(n-1)/2){
pll now=get(last.F+1,last.S-1);
last=now;
A.pb(now.F);
A.pb(now.S);
}
ll ans=0;
sort(all(A));
f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
return ans;
}
if(T==2){
vector<ll> A;
ll ans=0;
pll p=get(0,inf);
ll s=p.F,e=p.S,len=P(e-s,n-1);
ans=len;
A.pb(s);
A.pb(e);
for(ll l=s;l<=e;l+=len+1){
pll p=get(l,l+len);
A.pb(p.F);
A.pb(p.S);
}
sort(all(A));
f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
return ans;
}
return 0ll;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
53 | f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
| ~~~~~~~~~~~~
gap.cpp:53:3: note: in expansion of macro 'f'
53 | f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
| ^
gap.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
70 | f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
| ~~~~~~~~~~~~
gap.cpp:70:3: note: in expansion of macro 'f'
70 | f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |