Submission #928074

#TimeUsernameProblemLanguageResultExecution timeMemory
928074EJIC_B_KEDAXCarnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "tickets.h" using ll = long long; using namespace std; ll find_maximum(int k, vector<vector<int>> t) { int n = t.size(), m = t[0].size(); vector<int> all; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { all.push_back(t[i][j]); } } sort(all.begin(), all.end()); int middle = all[all.size() / 2]; ll res = 0; vector<pair<ll, int>> a(n); vector<int> bg(n, 0), end(n, m - 1); vector<vector<int>> s(n, vector<int>(m, -1)); for (int i = 0; i < n; i++) { a[i].first = 0; a[i].second = i; for (int j = 0; j < m; j++) { t[i][j] -= middle; a[i].first += t[i][j]; } } for (int r = 0; r < k; r++) { vector<int> nw; sort(a.begin(), a.end()); for (int i = 0; i < n / 2; i++) { a[i].first -= t[a[i].second][bg[a[i].second]]; nw.push_back(t[a[i].second][bg[a[i].second]]); s[a[i].second][bg[a[i].second]++] = r; } for (int i = n / 2; i < n; i++) { a[i].first -= t[a[i].second][end[a[i].second]]; nw.push_back(t[a[i].second][end[a[i].second]]); s[a[i].second][end[a[i].second]--] = r; } for (int i : nw) { res += abs(nw); } assert(0 >= nw[n / 2 - 1] && 0 <= nw[n / 2]); } allocate_tickets(s); return res; }

Compilation message (stderr)

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:44:26: error: no matching function for call to 'abs(std::vector<int>&)'
   44 |             res += abs(nw);
      |                          ^
In file included from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tickets.cpp:1:
/usr/include/stdlib.h:840:12: note: candidate: 'int abs(int)'
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:840:21: note:   no known conversion for argument 1 from 'std::vector<int>' to 'int'
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |                 ~~~~^~~
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:445:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const std::valarray<_Tp>&)'
  445 |     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:445:5: note:   template argument deduction/substitution failed:
tickets.cpp:44:26: note:   'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
   44 |             res += abs(nw);
      |                          ^
In file included from /usr/include/c++/10/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/valarray_after.h:445:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  445 |     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/valarray_after.h:445:5: note:   template argument deduction/substitution failed:
tickets.cpp:44:26: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   44 |             res += abs(nw);
      |                          ^
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from tickets.cpp:1:
/usr/include/c++/10/complex:625:5: note: candidate: 'template<class _Tp> _Tp std::abs(const std::complex<_Tp>&)'
  625 |     abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
      |     ^~~
/usr/include/c++/10/complex:625:5: note:   template argument deduction/substitution failed:
tickets.cpp:44:26: note:   'std::vector<int>' is not derived from 'const std::complex<_Tp>'
   44 |             res += abs(nw);
      |                          ^
In file included from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:79:19: note:   no known conversion for argument 1 from 'std::vector<int>' to 'long double'
   79 |   abs(long double __x)
      |       ~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:75:13: note:   no known conversion for argument 1 from 'std::vector<int>' to 'float'
   75 |   abs(float __x)
      |       ~~~~~~^~~
/usr/include/c++/10/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:71:14: note:   no known conversion for argument 1 from 'std::vector<int>' to 'double'
   71 |   abs(double __x)
      |       ~~~~~~~^~~
/usr/include/c++/10/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++/10/bits/std_abs.h:61:17: note:   no known conversion for argument 1 from 'std::vector<int>' to 'long long int'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |       ~~~~~~~~~~^~~
/usr/include/c++/10/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:56:12: note:   no known conversion for argument 1 from 'std::vector<int>' to 'long int'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |       ~~~~~^~~
tickets.cpp:43:18: warning: unused variable 'i' [-Wunused-variable]
   43 |         for (int i : nw) {
      |                  ^