Submission #23536

# Submission time Handle Problem Language Result Execution time Memory
23536 2017-05-12T13:26:06 Z repeating Gap (APIO16_gap) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll unsigned long long
#define pll pair<ll,ll>
#define SF(x) scanf("%I64d",&x)

using namespace std;
const long long INF = 2e9;
long long MOD = 1e9+7;
void MinMax(ll ,ll ,ll *,ll *);
//ll ar[12];
//void MinMax(ll s,ll e,ll *mn,ll *mx){
//    *mn=-1;
//    *mx=-1;
//    for(int i=0;i<10;i++){
//        if(s<=ar[i]&&ar[i]<=e){
//            if(*mn!=-1)*mn=min(*mn,ar[i]);
//            else *mn=ar[i];
//            if(*mx!=-1)*mx=max(*mx,ar[i]);
//            else *mx=ar[i];
//        }
//    }
//}
long long findGap(int ,int );
ll a[300006];
vector<pll> v[3];
vector<ll> arr;
long long findGap(int t,int n){
    if(t==1){
        ll l=0,r=1e18;
        ll res=0;
        ll i=0,j=n-1;
        W(i<=j){
            MinMax(l,r,&l,&r);
            a[i]=l;
            a[j]=r;
            r--,l++;
            i++,j--;
        }
        for(int i=1;i<n;i++)res=max(res,a[i]-a[i-1]);
        R res;
    }
    else{
        v[0].pb({0,1e18});
        ll cur=0;
        W(!v[cur].empty()){
            ll sum=0;
            for(int i=0;i<v[cur].SI;i++){
                sum+=v[cur][i].S-v[cur][i].F+1;
            }
            ll len=sum/100000;
            ll i;
            ll mx,mn;
//            cout<<sum<<endl;
            W(!v[cur].empty()){
                i=v[cur].SI-1;
                for(ll j=v[cur][i].F;j<=v[cur][i].S;j+=len){
                    MinMax(j,min(j+len-1,v[cur][i].S),&mn,&mx);
//                    cout<<j<<endl;
                    if(mn==-1)C;
                    arr.pb(mn);
                    if(mx!=mn)arr.pb(mx);
                    if(mn!=mx)v[cur^1].pb({mn+1,mx-1});
//                    cout<<mn<<" "<<mx<<endl;
                }
//                cout<<'s';
//                cout<<v[cur][0].F<<" "<<v[cur][0].S<<endl;
                v[cur].pop_back();
            }
            cur^=1;
        }
        ll res=0;
        sort(arr.begin(),arr.end());
        for(int i=1;i<arr.SI;i++){
            res=max(res,arr[i]-arr[i-1]);
        }
        R res;
    }
}
//int main(){
//    ar[0]=0;
//    ar[1]=5;
//    ar[2]=10;
//    for(int i=3;i<10;i++)ar[i]=ar[i-1]*100;
//    cout<<findGap(2,10);
//}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:56:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i=0;i<v[cur].SI;i++){
                          ^
gap.cpp:68:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     if(mn==-1)C;
                          ^
gap.cpp:82:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=1;i<arr.SI;i++){
                      ^
/tmp/ccdVg8YL.o: In function `findGap(int, int)':
gap.cpp:(.text+0x261): undefined reference to `MinMax(unsigned long long, unsigned long long, unsigned long long*, unsigned long long*)'
gap.cpp:(.text+0x40a): undefined reference to `MinMax(unsigned long long, unsigned long long, unsigned long long*, unsigned long long*)'
collect2: error: ld returned 1 exit status