답안 #978183

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978183 2024-05-09T02:37:08 Z Amaarsaa Gap (APIO16_gap) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
using ll =long long;
ll Sub1(ll N) {
	ll b[N + 2],ans, lo1, hi1, lo, hi, l, r;
	l = 1;
	r = N;
	lo = 0;
	hi = LONG_MAX;
	while ( l <= r) {
		MinMax(lo, hi, &lo1, &hi1);
		if (lo1 == -1) break;
		b[l] = lo1;
		b[r] = hi1;
		lo = lo1 + 1;
		hi = hi1 - 1;
		l ++;
		r --;
	}
	ans = 0;
	for (int i = 2; i <= N; i ++) {
		ans =max(ans, b[i] - b[i - 1]);
	}
	return ans;
}
ll Sub2(ll N) {
	
	ll l, r, x, y, ans, n = N;
	MinMax(0, 1e18, l, r);
	s = (r - l - 1)/(n - 1);
	ans = s;
	for ( i = l; i <= r; i += (s + 1)) {
		MinMax(i, i + s, &x, &y);
		if ( x != -1) {
			ans =max(ans, x - l);
			l = y;
		}
	}
	
	return ans;
}
long long findGap(int T, int N) {
	if ( T == 1) {
		return Sub1(N); 
	}
	else return Sub1(N);
}

Compilation message

gap.cpp: In function 'll Sub2(ll)':
gap.cpp:30:18: error: invalid conversion from 'll' {aka 'long long int'} to 'long long int*' [-fpermissive]
   30 |  MinMax(0, 1e18, l, r);
      |                  ^
      |                  |
      |                  ll {aka long long int}
In file included from gap.cpp:2:
gap.h:1:35: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                   ^~~~~~~~~~
gap.cpp:30:21: error: invalid conversion from 'll' {aka 'long long int'} to 'long long int*' [-fpermissive]
   30 |  MinMax(0, 1e18, l, r);
      |                     ^
      |                     |
      |                     ll {aka long long int}
In file included from gap.cpp:2:
gap.h:1:47: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                               ^~~~~~~~~~
gap.cpp:31:2: error: 's' was not declared in this scope
   31 |  s = (r - l - 1)/(n - 1);
      |  ^
gap.cpp:33:8: error: 'i' was not declared in this scope
   33 |  for ( i = l; i <= r; i += (s + 1)) {
      |        ^