Submission #925593

#TimeUsernameProblemLanguageResultExecution timeMemory
925593ReLiceGap (APIO16_gap)C++14
0 / 100
31 ms3016 KiB
#include "gap.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
//#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool f=0;
    if (x>y){x=y;f=1;}
    return f;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool f=0;
    if (x<y){x=y;f=1;}
    return f;
}
const ll inf=1e18+7;
const ll mod=1e9+7;
const ld eps=1e-9;
long long findGap(int t, int n){
    ll i;
	if(t==1){
        ll l=-inf,r=inf;
        ll ans=0;
        ll x,y;
        MinMax(l+1,r-1,&x,&y);
        l=x;
        r=y;
        for(i=0;i<(n+1)/2;i++){
            MinMax(l+1,r-1,&x,&y);
            chmax(ans,abs(x-l));
            chmax(ans,abs(y-r));
            l=x;
            r=y;
        }
        chmax(ans,abs(r-l));
        return ans;
	}
	ll l=-inf,r=inf;
	MinMax(l,r,&l,&r);
	ll k=(r-l+n-2)/(n-1);
	vll v;
	v.pb(l);
	for(i=0;i<(l+k-1)/k;i++){
        ll x,y;
        if(v.bc+k<r) MinMax(v.bc+1,v.bc+k,&x,&y);
        else MinMax(v.bc+1,r-1,&x,&y);
        v.pb(x);
        v.pb(y);
	}
	ll ans=0;
	v.pb(r);
	for(i=1;i<v.sz;i++){
        chmax(ans,v[i]-v[i-1]);
	}
	cout<<ans<<'*';
	return ans;
}

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:73:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |  for(i=1;i<v.sz;i++){
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...