Submission #640165

#TimeUsernameProblemLanguageResultExecution timeMemory
640165trunghieuWiring (IOI17_wiring)C++14
Compilation error
0 ms0 KiB
#include "wiring.h" //#include "grader.cpp" typedef long long ll; const int N = 205; const ll oo = 1e18; bool mark[N]; long long min_total_length(std::vector<int> r, std::vector<int> b) { int n = r.size(); int m = b.size(); if (n < m) { swap(n, m); swap(r, b); } ll rs = 0; for (int i = 0; i < m; ++i) { ll Min = oo; int pos = -1; for (int j = 0; j < n; ++j) if (!mark[j]) { if (abs(r[j] - b[i]) < Min) { Min = abs(r[j] - b[i]); pos = j; } } mark[pos] = 1; rs += Min; } for (int i = 0; i < n; ++i) if (!mark[i]) { ll Min = oo; for (int j = 0; j < m; ++j) Min = min(Min, (ll)abs(r[i] - b[j])); rs += Min; } return rs; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:11:9: error: 'swap' was not declared in this scope
   11 |         swap(n, m);
      |         ^~~~
wiring.cpp:11:9: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:68,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_bvector.h:134:3: note:   'std::swap'
  134 |   swap(bool& __x, _Bit_reference __y) noexcept
      |   ^~~~
In file included from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/new:41,
                 from /usr/include/c++/10/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 from /usr/include/c++/10/vector:64,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
wiring.cpp:19:17: error: 'abs' was not declared in this scope
   19 |             if (abs(r[j] - b[i]) < Min) {
      |                 ^~~
wiring.cpp:29:56: error: 'abs' was not declared in this scope
   29 |         for (int j = 0; j < m; ++j) Min = min(Min, (ll)abs(r[i] - b[j]));
      |                                                        ^~~
wiring.cpp:29:43: error: 'min' was not declared in this scope; did you mean 'std::min'?
   29 |         for (int j = 0; j < m; ++j) Min = min(Min, (ll)abs(r[i] - b[j]));
      |                                           ^~~
      |                                           std::min
In file included from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~