Submission #38809

# Submission time Handle Problem Language Result Execution time Memory
38809 2018-01-06T16:08:26 Z Waschbar Gap (APIO16_gap) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
 
const long long INF = 1e18;
 
long long findGap(int T, int N) {
 
	multiset < pair< long long,pair<long long,long long> > > st;
	long long mn, mx;
	MinMax(0ll,INF,&mn,&mx);
	st.insert({-(mx-mn),{mn,mx}});
	long long ans = 0;
 
    if(N == 2){
        return mx - mn;
    }
	
	if (T == 1){
		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;
	}
	
    long long mnds = (mx-mn)/N;
    vector < int > v;
    long long lst = mn;
    
    for(int i = mn; i <= mx; i+=dis)
	   long long a, b;
       MinMax(i,i+dis,&a,&b);
       if(a != -1){
           ans = max(ans,a-lst);
           lst = b;
       }
	}
 
	return ans;
 
	return 0;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:36:33: error: 'dis' was not declared in this scope
     for(int i = mn; i <= mx; i+=dis)
                                 ^
gap.cpp:37:15: warning: unused variable 'a' [-Wunused-variable]
     long long a, b;
               ^
gap.cpp:37:18: warning: unused variable 'b' [-Wunused-variable]
     long long a, b;
                  ^
gap.cpp:38:15: error: 'i' was not declared in this scope
        MinMax(i,i+dis,&a,&b);
               ^
gap.cpp:38:19: error: 'dis' was not declared in this scope
        MinMax(i,i+dis,&a,&b);
                   ^
gap.cpp:38:24: error: 'a' was not declared in this scope
        MinMax(i,i+dis,&a,&b);
                        ^
gap.cpp:38:27: error: 'b' was not declared in this scope
        MinMax(i,i+dis,&a,&b);
                           ^
gap.cpp:32:15: warning: unused variable 'mnds' [-Wunused-variable]
     long long mnds = (mx-mn)/N;
               ^
gap.cpp: At global scope:
gap.cpp:45:2: error: expected unqualified-id before 'return'
  return ans;
  ^
gap.cpp:47:2: error: expected unqualified-id before 'return'
  return 0;
  ^
gap.cpp:48:1: error: expected declaration before '}' token
 }
 ^
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:43:2: warning: control reaches end of non-void function [-Wreturn-type]
  }
  ^