Submission #61131

# Submission time Handle Problem Language Result Execution time Memory
61131 2018-07-25T08:33:00 Z dukati8 Gap (APIO16_gap) C++14
Compilation error
0 ms 0 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a; i<int(b); i++)

long long findGap(int T, int N)
{
	if (T==1) {
		vector<long long> vals;
		long long hi=1e18;
		long long lo=0;
		long long ans1,ans2;
		rep (i,0,(N+1)/2) {
			assert(lo<=hi);
			MinMax(lo,hi,&ans1,&ans2);
			vals.push_back(ans1);
			vals.push_back(ans2);
			lo=ans1+1;
			hi=ans2-1;
		}
		sort(vals.begin(),vals.end());
		long long maxdist=0;
		rep (i,0,vals.size()-1) {
			maxdist=max(maxdist,vals[i+1]-vals[i]);
			//cout << maxdist << endl;
		}
		return maxdist;
	}
	if (T==2) {
		long long NL=long long(N);
		vector<long long> vals;
		long long hi,lo;
		MinMax(0,1e18,&lo,&hi);
		//Vi har nu max och min för alla tal.
		long long expdist=(hi-lo)/(NL-1);
		vals.push_back(hi);
		vals.push_back(lo);
		rep (i,0,N-1) {
			long long start,stop;
			start=lo+1+(i*(hi-lo-1))/(NL-1);
			stop=lo+((i+1)*(hi-lo-1))/(NL-1);
			assert(start<=stop);
			long long ans1,ans2;
			MinMax(start,stop,&ans1,&ans2);
			if (ans1!=-1) vals.push_back(ans1);
			if (ans2!=-1) vals.push_back(ans2);
		}
		sort(vals.begin(),vals.end());
		long long maxdist=0;
		rep (i,0,vals.size()-1) maxdist=max(maxdist,vals[i+1]-vals[i]);
		assert(maxdist>=expdist);
		return maxdist;
	}

}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:30:16: error: expected primary-expression before 'long'
   long long NL=long long(N);
                ^~~~
gap.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^