Submission #211067

#TimeUsernameProblemLanguageResultExecution timeMemory
211067lyhArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" long long count_swaps(std::vector<int> s) { long long sum = 0; for (int i = 0; i < (int)S.size(); i += 2) { int k; for (k = i; k < (int)S.size(); k++) { if (S[k] > 0) break; } for (int j = k; j > i; j--) { swap(S[j], S[j - 1]); sum++; } for (k = i + 1; k < (int)S.size(); k++) { if (S[k] == -S[i]) { break; } } for (int j = k; j > i + 1; j--) { swap(S[j], S[j - 1]); sum++; } } return sum; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:27: error: 'S' was not declared in this scope
  for (int i = 0; i < (int)S.size(); i += 2)
                           ^
shoes.cpp:16:4: error: 'swap' was not declared in this scope
    swap(S[j], S[j - 1]);
    ^~~~
shoes.cpp:16:4: note: suggested alternatives:
In file included from /usr/include/c++/7/vector:65:0,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/stl_bvector.h:128:3: note:   'std::swap'
   swap(bool& __x, _Bit_reference __y) noexcept
   ^~~~
In file included from /usr/include/c++/7/bits/stl_pair.h:59:0,
                 from /usr/include/c++/7/bits/stl_algobase.h:64,
                 from /usr/include/c++/7/vector:60,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/move.h:187:5: note:   'std::swap'
     swap(_Tp& __a, _Tp& __b)
     ^~~~
In file included from /usr/include/c++/7/exception:142:0,
                 from /usr/include/c++/7/new:40,
                 from /usr/include/c++/7/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/vector:61,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/exception_ptr.h:166:5: note:   'std::__exception_ptr::swap'
     swap(exception_ptr& __lhs, exception_ptr& __rhs)
     ^~~~
shoes.cpp:28:4: error: 'swap' was not declared in this scope
    swap(S[j], S[j - 1]);
    ^~~~
shoes.cpp:28:4: note: suggested alternatives:
In file included from /usr/include/c++/7/vector:65:0,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/stl_bvector.h:128:3: note:   'std::swap'
   swap(bool& __x, _Bit_reference __y) noexcept
   ^~~~
In file included from /usr/include/c++/7/bits/stl_pair.h:59:0,
                 from /usr/include/c++/7/bits/stl_algobase.h:64,
                 from /usr/include/c++/7/vector:60,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/move.h:187:5: note:   'std::swap'
     swap(_Tp& __a, _Tp& __b)
     ^~~~
In file included from /usr/include/c++/7/exception:142:0,
                 from /usr/include/c++/7/new:40,
                 from /usr/include/c++/7/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/vector:61,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/exception_ptr.h:166:5: note:   'std::__exception_ptr::swap'
     swap(exception_ptr& __lhs, exception_ptr& __rhs)
     ^~~~