Submission #396206

#TimeUsernameProblemLanguageResultExecution timeMemory
396206CyanmondGap (APIO16_gap)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" #pragma region template using llint = long long; using isize = std::ptrdiff_t; using usize = std::size_t; template <class T> [[nodiscard]] inline T read() { T ret; std::cin >> ret; return ret; } template <class T> auto mk_vec(const int n, const T value) { return std::vector(n, value); } template <class... Args> auto mk_vec(const int n, Args... args) { return std::vector(n, mk_vec(args...)); } template <class T, class = std::enable_if_t<std::is_signed_v<T>>> class range { struct range_iterator { T itr; constexpr range_iterator(const int pos) noexcept : itr(pos) {} constexpr void operator++() noexcept { ++itr; } constexpr bool operator!=(const range_iterator& other) const noexcept { return itr != other.itr; } constexpr T operator*() const noexcept { return itr; } }; public: constexpr range(const T first_, const T last_) noexcept : first(first_), last(last_) {} constexpr range_iterator begin() const noexcept { return first; } constexpr range_iterator end() const noexcept { return last; } private: const range_iterator first, last; }; template <class T, class = std::enable_if_t<std::is_signed_v<T>>> class revrange { struct revrange_iterator { T itr; constexpr revrange_iterator(const int pos) noexcept : itr(pos) {} constexpr void operator++() noexcept { --itr; } constexpr bool operator!=(const revrange_iterator& other) const noexcept { return itr != other.itr; } constexpr T operator*() const noexcept { return itr; } }; public: constexpr revrange(const T first_, const T last_) noexcept : first(first_), last(last_ - 1) {} constexpr revrange_iterator begin() const noexcept { return first; } constexpr revrange_iterator end() const noexcept { return last; } private: const revrange_iterator first, last; }; template <class F> class rec_lambda { public: constexpr rec_lambda(F&& f_) : f(std::forward<F>(f_)) {} template <class... Args> constexpr auto operator()(Args&&... args) const { return f(*this, std::forward<Args>(args)...); } private: F f; }; #pragma endregion #ifdef _MSC_VER // Sample program constexpr std::array<llint, 4> sample = {2, 3, 6, 8}; constexpr int sampleN = 4; void MinMax(llint s, llint t, llint& mn, llint& mx) { const auto itr1 = std::lower_bound(sample.begin(), sample.end(), s); const auto itr2 = std::upper_bound(sample.begin(), sample.end(), t); if (itr1 == sample.end() or itr2 == sample.begin() or itr1 == itr2) { mn = mx = -1; return; } mn = *itr1; mx = *(itr2 - 1); } #endif #include "gap.h" llint findGap(int T, int N) { /* std::ios::sync_with_stdio(false); std::cin.tie(nullptr); */ if (T == 1) { // T = 1 std::vector<llint> A(N); llint L = -1, R = 1ll << 62; int cnt = 0; while (cnt < ((N + 1) >> 1)) { llint nxL, nxR; MinMax(L, R, nxL, nxR); if (nxL == -1 and nxR == -1) continue; A[cnt] = nxL; A[N - cnt - 1] = nxR; ++cnt; L = ++nxL; R = --nxR; } llint answer = 0; for (int i : range(0, N - 1)) if (answer < A[i + 1] - A[i]) answer = A[i + 1] - A[i]; return answer; } if (T == 2) { // yet... return 0ll; } }

Compilation message (stderr)

gap.cpp:2: warning: ignoring #pragma region template [-Wunknown-pragmas]
    2 | #pragma region template
      | 
gap.cpp:79: warning: ignoring #pragma endregion  [-Wunknown-pragmas]
   79 | #pragma endregion
      | 
gap.cpp: In function 'llint findGap(int, int)':
gap.cpp:111:20: error: invalid conversion from 'llint' {aka 'long long int'} to 'long long int*' [-fpermissive]
  111 |       MinMax(L, R, nxL, nxR);
      |                    ^~~
      |                    |
      |                    llint {aka long long int}
In file included from gap.cpp:97:
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:111:25: error: invalid conversion from 'llint' {aka 'long long int'} to 'long long int*' [-fpermissive]
  111 |       MinMax(L, R, nxL, nxR);
      |                         ^~~
      |                         |
      |                         llint {aka long long int}
In file included from gap.cpp:97:
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:128:1: warning: control reaches end of non-void function [-Wreturn-type]
  128 | }
      | ^