Submission #230422

# Submission time Handle Problem Language Result Execution time Memory
230422 2020-05-10T06:19:27 Z NONAME Pismo (COCI18_pismo) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define ft first
#define sd second
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
using namespace std;
typedef long long ll;
typedef long double ld;

int n, a[N], ans = -1;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < n - 1; i++)
        ans = (ans == -1 ? abs(a[i] - a[i + 1]) : min(ans, abs(a[i], a[i - 1])));

    cout << ans;
}

Compilation message

pismo.cpp: In function 'int main()':
pismo.cpp:28:78: error: no matching function for call to 'abs(int&, int&)'
         ans = (ans == -1 ? abs(a[i] - a[i + 1]) : min(ans, abs(a[i], a[i - 1])));
                                                                              ^
In file included from /usr/include/c++/7/bits/std_abs.h:38:0,
                 from /usr/include/c++/7/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from pismo.cpp:1:
/usr/include/stdlib.h:774:12: note: candidate: int abs(int)
 extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
            ^~~
/usr/include/stdlib.h:774:12: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/7/cmath:47:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from pismo.cpp:1:
/usr/include/c++/7/bits/std_abs.h:56:3: note: candidate: long int std::abs(long int)
   abs(long __i) { return __builtin_labs(__i); }
   ^~~
/usr/include/c++/7/bits/std_abs.h:56:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/7/bits/std_abs.h:61:3: note: candidate: long long int std::abs(long long int)
   abs(long long __x) { return __builtin_llabs (__x); }
   ^~~
/usr/include/c++/7/bits/std_abs.h:61:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/7/bits/std_abs.h:70:3: note: candidate: constexpr double std::abs(double)
   abs(double __x)
   ^~~
/usr/include/c++/7/bits/std_abs.h:70:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/7/bits/std_abs.h:74:3: note: candidate: constexpr float std::abs(float)
   abs(float __x)
   ^~~
/usr/include/c++/7/bits/std_abs.h:74:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/7/bits/std_abs.h:78:3: note: candidate: constexpr long double std::abs(long double)
   abs(long double __x)
   ^~~
/usr/include/c++/7/bits/std_abs.h:78:3: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/7/ccomplex:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from pismo.cpp:1:
/usr/include/c++/7/complex:599:5: note: candidate: template<class _Tp> _Tp std::abs(const std::complex<_Tp>&)
     abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
     ^~~
/usr/include/c++/7/complex:599:5: note:   template argument deduction/substitution failed:
pismo.cpp:28:78: note:   mismatched types 'const std::complex<_Tp>' and 'int'
         ans = (ans == -1 ? abs(a[i] - a[i + 1]) : min(ans, abs(a[i], a[i - 1])));
                                                                              ^
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from pismo.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:442:5: note: candidate: template<class _Dom> std::_Expr<std::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const std::_Expr<_Dom1, typename _Dom1::value_type>&)
     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
     ^
/usr/include/c++/7/bits/valarray_after.h:442:5: note:   template argument deduction/substitution failed:
pismo.cpp:28:78: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
         ans = (ans == -1 ? abs(a[i] - a[i + 1]) : min(ans, abs(a[i], a[i - 1])));
                                                                              ^
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from pismo.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:442:5: note: candidate: template<class _Tp> std::_Expr<std::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const std::valarray<_Tp>&)
     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
     ^
/usr/include/c++/7/bits/valarray_after.h:442:5: note:   template argument deduction/substitution failed:
pismo.cpp:28:78: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
         ans = (ans == -1 ? abs(a[i] - a[i + 1]) : min(ans, abs(a[i], a[i - 1])));
                                                                              ^