Submission #47678

#TimeUsernameProblemLanguageResultExecution timeMemory
47678tieunhiGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; long long findGap(int T, int N) { long long mn, mx, mmn, mmx; MinMax(0, 2e18, &mn, &mx); long long res = 0; if (T == 1) { for (int i = 1; i < (N+1)/2; i++) { MinMax(mn+1, mx-1, &mmn, &mmx); if (mmn == -1) break; res = max({res, mmn-mn, mx-mmx}); mn = mmn; mx = mmx; } ans = max(mx - mn); } else { long long sz = (mx - mn + N - 1)/N; long long last = mn; for (long long b = mn+1, e = mn+sz; ; b += sz, e += sz) { if (e >= mx) e = mx - 1; if (b > e) break; MinMax(b, e, &mmn, &mmx); if (mmn == -1) continue; res = max(res, mmn - last); last = mmx; } res = max(res, mx - last); } return res; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:21:9: error: 'ans' was not declared in this scope
         ans = max(mx - mn);
         ^~~
gap.cpp:21:9: note: suggested alternative: 'abs'
         ans = max(mx - mn);
         ^~~
         abs
gap.cpp:21:26: error: no matching function for call to 'max(long long int)'
         ans = max(mx - mn);
                          ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from gap.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
gap.cpp:21:26: note:   candidate expects 2 arguments, 1 provided
         ans = max(mx - mn);
                          ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from gap.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
gap.cpp:21:26: note:   candidate expects 3 arguments, 1 provided
         ans = max(mx - mn);
                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from gap.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
gap.cpp:21:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         ans = max(mx - mn);
                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from gap.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
gap.cpp:21:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         ans = max(mx - mn);
                          ^