답안 #38783

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38783 2018-01-06T14:14:47 Z Waschbar Gap (APIO16_gap) C++14
컴파일 오류
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 dis = (mx-mn)/n;
	vector < pair<long long,long long> > v;
	for(long long i = mn; i <= mx; i++){
        long long a, b;
        MinMax(i,i+dis,a,b);
        v.push_back({a,b});
	}
 
    for(int i = 0; i < v.size(); i++)
        ans = max(ans,v[i].second-v[i].first);
    
	return ans;
 
	return 0;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:32:26: error: 'n' was not declared in this scope
  long long dis = (mx-mn)/n;
                          ^
gap.cpp:36:27: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
         MinMax(i,i+dis,a,b);
                           ^
In file included from gap.cpp:2:0:
gap.h:1:6: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^
gap.cpp:36:27: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
         MinMax(i,i+dis,a,b);
                           ^
In file included from gap.cpp:2:0:
gap.h:1:6: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^
gap.cpp:40:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size(); i++)
                      ^