Submission #1164252

#TimeUsernameProblemLanguageResultExecution timeMemory
1164252ali2241Palembang Bridges (APIO15_bridge)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define int long long #define arr2 array<int, 2> #define arr3 array<int, 3> #define all(a) a.begin(), a.end() #define double long double // #pragma GCC target("avx2") using namespace std; using namespace __gnu_pbds; template<class T> using rb3 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T> using mrb3 = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 1e5 + 10, M = 998244353; int cost = 0; int abs(int a) { return (a < 0 ? -a : a); } void fun() { int k, n; cin >> k >> n; vector<int> pnt; for (int i = 0; i < n; ++i) { char a, c; int b, d; cin >> a >> b >> c >> d; if (a == c) { cost += d - b; } else { cost++; pnt.push_back(b); pnt.push_back(d); } } sort(all(pnt)); if (pnt.size()) { int mid = pnt[(pnt.size()) / 2]; for (int i : pnt) { cost += abs(i - mid); } } cout << cost << "\n"; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // int tc; // cin >> tc; // while (tc--) fun(); }

Compilation message (stderr)

bridge.cpp: In function 'void fun()':
bridge.cpp:47:24: error: call of overloaded 'abs(long long int)' is ambiguous
   47 |             cost += abs(i - mid);
      |                     ~~~^~~~~~~~~
In file included from /usr/include/c++/11/bits/std_abs.h:38,
                 from /usr/include/c++/11/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from bridge.cpp:1:
/usr/include/stdlib.h:848:12: note: candidate: 'int abs(int)'
  848 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
bridge.cpp:22:5: note: candidate: 'long long int abs(long long int)'
   22 | int abs(int a) {
      |     ^~~
In file included from /usr/include/c++/11/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from bridge.cpp:1:
/usr/include/c++/11/bits/std_abs.h:103:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  103 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/11/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/11/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/11/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/11/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/11/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/11/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~