Submission #1014290

# Submission time Handle Problem Language Result Execution time Memory
1014290 2024-07-04T16:09:13 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) {
		int l = 0, r = inff;
		vector<long long> a(n);
		for (int i = 0; i < (n + 1) / 2; i++) {
			int mn, mx;
			MinMax(l, r, &mn, &mx);
			a[i] = mn;
			a[n - 1 - i] = mx;
			l = mn + 1;
			r = mx - 1;
		}

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

		return res;
	} else if (t == 2) {
		
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:10:18: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   10 |   int l = 0, r = inff;
      |                  ^~~~
gap.cpp:14:17: error: cannot convert 'int*' to 'long long int*'
   14 |    MinMax(l, r, &mn, &mx);
      |                 ^~~
      |                 |
      |                 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:28:1: warning: control reaches end of non-void function [-Wreturn-type]
   28 | }
      | ^