Submission #925596

#TimeUsernameProblemLanguageResultExecution timeMemory
925596ReLiceGap (APIO16_gap)C++14
100 / 100
45 ms5020 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,j;
    ll a,b,c,d,l,r;
    a=1,b=inf;
    MinMax(a,b,&c,&d);
    vector <ll> v;
    v.pb(c),v.pb(d);
    r=d,l=c;
    ll ans=0;
	if(t==1){
        for(i=1;i<(n+1)/2;i++){
            a=c+1;
            b=d-1;
            MinMax(a,b,&c,&d);
            v.pb(c);
            v.pb(d);
        }
	}
	else{
        j=(d-c-1)%(n-1);
        for(i=l+1;i<r;i+=(r-l-1)/(n-1)){
            a=i;
            if(j>0){
                i++;
                j--;
            }
            b=i+(r-l-1)/(n-1)-1;
            MinMax(a,b,&c,&d);
            if(c==-1) continue;
            v.pb(c);
            v.pb(d);
        }
	}
    sort(v.begin(),v.end());
    for(i=1;i<v.sz;i++){
        ans=max(ans,v[i]-v[i-1]);
    }
    return ans;
}

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:74:14: 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]
   74 |     for(i=1;i<v.sz;i++){
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...