Submission #104992

# Submission time Handle Problem Language Result Execution time Memory
104992 2019-04-10T04:47:33 Z puyu_liao Gap (APIO16_gap) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 300006

//vector<int> vv;
//void MinMax(long long s, long long t, long long* mn, long long* mx){
//	cout << "ASKed " << s << ' ' << t << '\n';
//	auto imn = lower_bound(vv.begin(),vv.end(),s);
//	auto imx = upper_bound(vv.begin(),vv.end(),t);
//	if(imn == vv.end() || imx == vv.begin() || *imn > *--imx) {
//		cout << "return (-1,-1)" << '\n';
//		return *mn = *mx = -1ll, void();
//	}
//	*mn = *imn;
//	*mx = *imx;
//	cout << "return " << complex<int>(*mn,*mx) << '\n';
//}

//#include "gap.h"
typedef long long ll;

ll nowmx;
vector<ll> v;
void qur(ll l,ll r){
	if(l > r || r-l <= nowmx) return;
	ll mn,mx;
	if(l+1 == r){
		MinMax(l,r,&mn,&mx);
		nowmx = max(nowmx,mn-mx);
		if(mn == -1) return;
		v.push_back(mn);
		if(mn != mx) v.push_back(mx);
		return;
	}
	ll m = l+r>>1;
	MinMax(l,m,&mn,&mx);
	if(mn != -1) {
		v.push_back(mn);
		if(mn != mx) v.push_back(mx);
		qur(mn+1,mx-1);
	}
	else nowmx = max(nowmx,m-l);
	MinMax(m+1,r,&mn,&mx);
	if(mn != -1) {
		v.push_back(mn);
		if(mn != mx) v.push_back(mx);
		qur(mn+1,mx-1);
	}else nowmx = max(nowmx,r-m-1);
}

ll findGap(int T,int n){
	if(T==1){
		vector<ll> v1,v2;
		ll ans = 0;
		ll s = 0, t = 1000000000000000000ll,mn,mx;
		for(int i=1,j=n;i<=j;i++,j--){
			MinMax(s,t,&mn,&mx);
			v1.push_back(mn);
			if(i != j) v2.push_back(mx);
			s = mn+1; t=mx-1;
		}
		reverse(v2.begin(),v2.end());
		for(ll i : v2) v1.push_back(i);
		for(int i=0;i<v1.size()-1;i++) ans = max(ans,v1[i+1]-v1[i]);
		return ans;
	}
	else{
		ll ans = 0;
		ll s = 0, t = 1000000000000000000ll,mn,mx;
		MinMax(s,t,&mn,&mx); v.push_back(mn); v.push_back(mx);
		s = mn+1, t = mx-1;
		qur(s,t);
		sort(v.begin(),v.end());
		//for(int i : v) cout << i << ' '; cout << '\n';
		for(int i=0;i<v.size()-1;i++) ans = max(ans,v[i+1]-v[i]);
		return ans;
	}
}

Compilation message

gap.cpp: In function 'void qur(ll, ll)':
gap.cpp:30:3: error: 'MinMax' was not declared in this scope
   MinMax(l,r,&mn,&mx);
   ^~~~~~
gap.cpp:30:3: note: suggested alternative: 'rindex'
   MinMax(l,r,&mn,&mx);
   ^~~~~~
   rindex
gap.cpp:37:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  ll m = l+r>>1;
         ~^~
gap.cpp:38:2: error: 'MinMax' was not declared in this scope
  MinMax(l,m,&mn,&mx);
  ^~~~~~
gap.cpp:38:2: note: suggested alternative: 'rindex'
  MinMax(l,m,&mn,&mx);
  ^~~~~~
  rindex
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:59:4: error: 'MinMax' was not declared in this scope
    MinMax(s,t,&mn,&mx);
    ^~~~~~
gap.cpp:59:4: note: suggested alternative: 'rindex'
    MinMax(s,t,&mn,&mx);
    ^~~~~~
    rindex
gap.cpp:66:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<v1.size()-1;i++) ans = max(ans,v1[i+1]-v1[i]);
               ~^~~~~~~~~~~~
gap.cpp:72:3: error: 'MinMax' was not declared in this scope
   MinMax(s,t,&mn,&mx); v.push_back(mn); v.push_back(mx);
   ^~~~~~
gap.cpp:72:3: note: suggested alternative: 'rindex'
   MinMax(s,t,&mn,&mx); v.push_back(mn); v.push_back(mx);
   ^~~~~~
   rindex
gap.cpp:77:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<v.size()-1;i++) ans = max(ans,v[i+1]-v[i]);
               ~^~~~~~~~~~~