Submission #414651

#TimeUsernameProblemLanguageResultExecution timeMemory
414651hibye1217Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
/* shoes */ #ifndef NOTSUBMIT #include "shoes.h" #endif int psh(std::vector<int>& s, int st, int ed){ int res = 0; for (int j = st; j > ed; j--){ swap(s[j], s[j-1]); res += 1; } return res; } long long count_swaps(std::vector<int> s) { int n = s.size(); int ans = 0; for (int i = 0; i < n; i += 2){ int p = 0; for (int j = i; j < n; j++){ if (s[j] == -s[i]){ p = j; break; } } ans += psh(s, p, i+1); if (s[i] > s[i+1]){ swap(s[i], s[i+1]); ans += 1; } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'int psh(std::vector<int>&, int, int)':
shoes.cpp:10:3: error: 'swap' was not declared in this scope
   10 |   swap(s[j], s[j-1]);
      |   ^~~~
shoes.cpp:10:3: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:68,
                 from shoes.h:5,
                 from shoes.cpp:4:
/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 shoes.h:5,
                 from shoes.cpp:4:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
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 shoes.h:5,
                 from shoes.cpp:4:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:25:23: error: 'swap' was not declared in this scope
   25 |   if (s[i] > s[i+1]){ swap(s[i], s[i+1]); ans += 1; }
      |                       ^~~~
shoes.cpp:25:23: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:68,
                 from shoes.h:5,
                 from shoes.cpp:4:
/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 shoes.h:5,
                 from shoes.cpp:4:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
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 shoes.h:5,
                 from shoes.cpp:4:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~