답안 #104991

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104991 2019-04-10T04:46:45 Z puyu_liao Gap (APIO16_gap) C++14
컴파일 오류
0 ms 0 KB
#include "gap.h"
typedef long long ll;

ll nowmx;
vector<ll> v;
void qur(ll l,ll r){
	int cnt = 0;
	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:6:1: error: 'vector' does not name a type
 vector<ll> v;
 ^~~~~~
gap.cpp: In function 'void qur(ll, ll)':
gap.cpp:13:11: error: 'max' was not declared in this scope
   nowmx = max(nowmx,mn-mx);
           ^~~
gap.cpp:13:11: note: suggested alternative: 'mx'
   nowmx = max(nowmx,mn-mx);
           ^~~
           mx
gap.cpp:15:3: error: 'v' was not declared in this scope
   v.push_back(mn);
   ^
gap.cpp:19:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  ll m = l+r>>1;
         ~^~
gap.cpp:22:3: error: 'v' was not declared in this scope
   v.push_back(mn);
   ^
gap.cpp:26:15: error: 'max' was not declared in this scope
  else nowmx = max(nowmx,m-l);
               ^~~
gap.cpp:26:15: note: suggested alternative: 'mx'
  else nowmx = max(nowmx,m-l);
               ^~~
               mx
gap.cpp:29:3: error: 'v' was not declared in this scope
   v.push_back(mn);
   ^
gap.cpp:32:16: error: 'max' was not declared in this scope
  }else nowmx = max(nowmx,r-m-1);
                ^~~
gap.cpp:32:16: note: suggested alternative: 'mx'
  }else nowmx = max(nowmx,r-m-1);
                ^~~
                mx
gap.cpp:8:6: warning: unused variable 'cnt' [-Wunused-variable]
  int cnt = 0;
      ^~~
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:37:3: error: 'vector' was not declared in this scope
   vector<ll> v1,v2;
   ^~~~~~
gap.cpp:37:12: error: expected primary-expression before '>' token
   vector<ll> v1,v2;
            ^
gap.cpp:37:14: error: 'v1' was not declared in this scope
   vector<ll> v1,v2;
              ^~
gap.cpp:37:17: error: 'v2' was not declared in this scope
   vector<ll> v1,v2;
                 ^~
gap.cpp:46:3: error: 'reverse' was not declared in this scope
   reverse(v2.begin(),v2.end());
   ^~~~~~~
gap.cpp:47:14: error: unable to deduce 'auto&&' from 'v2'
   for(ll i : v2) v1.push_back(i);
              ^~
gap.cpp:48:40: error: 'max' was not declared in this scope
   for(int i=0;i<v1.size()-1;i++) ans = max(ans,v1[i+1]-v1[i]);
                                        ^~~
gap.cpp:48:40: note: suggested alternative: 'mx'
   for(int i=0;i<v1.size()-1;i++) ans = max(ans,v1[i+1]-v1[i]);
                                        ^~~
                                        mx
gap.cpp:54:24: error: 'v' was not declared in this scope
   MinMax(s,t,&mn,&mx); v.push_back(mn); v.push_back(mx);
                        ^
gap.cpp:57:3: error: 'sort' was not declared in this scope
   sort(v.begin(),v.end());
   ^~~~
gap.cpp:57:3: note: suggested alternative: 'short'
   sort(v.begin(),v.end());
   ^~~~
   short
gap.cpp:59:39: error: 'max' was not declared in this scope
   for(int i=0;i<v.size()-1;i++) ans = max(ans,v[i+1]-v[i]);
                                       ^~~
gap.cpp:59:39: note: suggested alternative: 'mx'
   for(int i=0;i<v.size()-1;i++) ans = max(ans,v[i+1]-v[i]);
                                       ^~~
                                       mx