Submission #1014300

# Submission time Handle Problem Language Result Execution time Memory
1014300 2024-07-04T16:15:40 Z aufan Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;

const long long inff = 1e18;

long long findGap(int t, int n) {
	if (t == 1) {
		long long l = 0, r = inff;
		vector<long long> a(n);
		for (int i = 0; i < (n + 1) / 2; i++) {
			long long mn, mx;
			MinMax(l, r, &mn, &mx);
			a[i] = mn;
			a[n - 1 - i] = mx;
			l = mn + 1;
			r = mx - 1;
		}

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

		return ans;
	} else if (t == 2) {
		long long l = 0, r = inff, mn, mx;
		MinMax(l, r, mn, mx);

		long long ans = (mx - mn) / (n - 1), lst = mn;
		l = mn + 1;
		r = mx;
		while (l < r) {
			MinMax(l, l + ans - 1, mn, mx);
			l += ans;
			ans = max(ans, mn - lst);
			if (mx != -1) lst = mx;
		}
		ans = max(ans, r - lst);

		return ans;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:16: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   27 |   MinMax(l, r, mn, mx);
      |                ^~
      |                |
      |                long long int
In file included from gap.cpp:1:
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:27:20: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   27 |   MinMax(l, r, mn, mx);
      |                    ^~
      |                    |
      |                    long long int
In file included from gap.cpp:1:
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:33:27: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   33 |    MinMax(l, l + ans - 1, mn, mx);
      |                           ^~
      |                           |
      |                           long long int
In file included from gap.cpp:1:
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:33:31: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   33 |    MinMax(l, l + ans - 1, mn, mx);
      |                               ^~
      |                               |
      |                               long long int
In file included from gap.cpp:1:
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:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^