답안 #42644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42644 2018-03-01T17:21:37 Z MatheusLealV Gap (APIO16_gap) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "gap.h"
#define N 100005
#define inf 2000000000000000000LL
using namespace std;
typedef long long ll;

ll n, v[N], ans[N];

vector<ll> val;

void solve(ll ini, ll fim)
{
	if(fim < ini) return;

	if(ini == fim)
	{
		val.push_back(ini);

		return;
	}

	ll mid = (ini + fim)/2;

	ll a, b;

	MinMax(mid + 1, fim, &a, &b);

	if(a != -1 && b != -1)
	{
		val.push_back(a);

		val.push_back(b);

		solve(a + 1, b - 1);
	}

	MinMax(ini, mid, &a, &b);

	if(a != -1 && b != -1)
	{
		val.push_back(a);

		val.push_back(b);
		
		solve(a + 1, b - 1);
	}
}

ll findGap(int T, int N_)
{
	ll best = 0;

	if(T == 1)
	{
		n = N_;

		ll esq = 0, dir = inf;

		for(int i = 1, st = 1, en = n; i <= (n + 1)/2; i++, st ++, en --)
		{
			ll a, b;

			MinMax(esq, dir, a, b);

			esq = a + 1, dir = b - 1;

			if(a != -1 && b != -1) ans[st] = a, ans[en] = b;
		}

		for(int i = 1; i <= n; i++) best = max(best, ans[i] - ans[i - 1]);

		return best;
	}

	else
	{
		solve(0, inf);

		sort(val.begin(), val.end());

		for(int i = 0; i < val.size(); i++)
			{
				if(i > 0) best = max(best, val[i] - val[i - 1]);
			}

		return best;
	}

}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:64:25: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
    MinMax(esq, dir, 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:64:25: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
    MinMax(esq, dir, 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:82:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < val.size(); i++)
                    ^