Submission #882304

# Submission time Handle Problem Language Result Execution time Memory
882304 2023-12-03T03:30:15 Z ono_de206 Gap (APIO16_gap) C++14
Compilation error
0 ms 0 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long

typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

long long findGap(int T, int N) {
	long long qn, qx;

	auto ask = [&](long long l, long long r) -> void {
		assert(l <= r);
		MinMax(l, r, &qn, &qx);
	};

	if(T == 1) {
		vector<long long> a(N);
		int l = 0, r = (long long)1e18;
		for(int i = 0, j = N - 1; i <= j; i++, j--) {
			ask(l, r);
			a[i] = qn;
			a[j] = qx;
			l = qn + 1;
			r = qx - 1;
		}
		int ans = 0;
		for(int i = 1; i < N; i++) {
			ans = max(ans, a[i] - a[i - 1]);
		}
		return ans;
	}

	long long sus1 = 0, sus2 = (long long)1e18;

	ask(sus1, sus2);

	long long mn = qn, mx = qx, ans = 0;
	long long d = (mx - mn + N - 1) / N;
	long long ls = mn, l = mn + 1;
	while(l <= mx) {
		long long r = l + d - 1;
		ask(l, r);
		if(qn != -1) {
			ans = max(ans, qn - ls);
			ls = qx;
		}
		l = r + 1;
	}
	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:31:18: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   31 |   int l = 0, r = (long long)1e18;
      |                  ^~~~~~~~~~~~~~~
gap.cpp:41:34: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   41 |    ans = max(ans, a[i] - a[i - 1]);
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from gap.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
gap.cpp:41:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   41 |    ans = max(ans, a[i] - a[i - 1]);
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from gap.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
gap.cpp:41:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   41 |    ans = max(ans, a[i] - a[i - 1]);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gap.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
gap.cpp:41:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   41 |    ans = max(ans, a[i] - a[i - 1]);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gap.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
gap.cpp:41:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   41 |    ans = max(ans, a[i] - a[i - 1]);
      |                                  ^