Submission #1215754

#TimeUsernameProblemLanguageResultExecution timeMemory
1215754SzilArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include "shoes.h" long long count_swaps(std::vector<int> s) { int n = s.size()/2; vector<int> v = s; for (int &i : v) cin >> i; vector<int> val; for (int i : v) { if (i > 0) val.emplace_back(i); } sort(val.begin(), val.end()); int ans = 1e9; do { vector<int> goal; for (int i : val) { goal.emplace_back(-i); goal.emplace_back(i); } vector<bool> done(2*n); vector<int> arr; for (int i = 0; i < 2*n; i++) { int j = 0; for (; j < 2*n; j++) { if (!done[j] && goal[j] == v[i]) { break; } } done[j] = 1; arr.emplace_back(j); } int curr = 0; for (int i = 0; i < 2*n; i++) { for (int j = 0; j < i; j++) { if (arr[j] > arr[i]) curr++; } } ans = min(ans, curr); } while (next_permutation(val.begin(), val.end())); return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:5:5: error: 'vector' was not declared in this scope
    5 |     vector<int> v = s;
      |     ^~~~~~
shoes.cpp:5:5: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/11/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
shoes.cpp:5:12: error: expected primary-expression before 'int'
    5 |     vector<int> v = s;
      |            ^~~
shoes.cpp:6:19: error: 'v' was not declared in this scope
    6 |     for (int &i : v) cin >> i;
      |                   ^
shoes.cpp:6:22: error: 'cin' was not declared in this scope
    6 |     for (int &i : v) cin >> i;
      |                      ^~~
shoes.cpp:8:12: error: expected primary-expression before 'int'
    8 |     vector<int> val;
      |            ^~~
shoes.cpp:9:18: error: 'v' was not declared in this scope
    9 |     for (int i : v) {
      |                  ^
shoes.cpp:10:20: error: 'val' was not declared in this scope
   10 |         if (i > 0) val.emplace_back(i);
      |                    ^~~
shoes.cpp:12:10: error: 'val' was not declared in this scope
   12 |     sort(val.begin(), val.end());
      |          ^~~
shoes.cpp:12:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   12 |     sort(val.begin(), val.end());
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/11/vector:62,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:4863:5: note: 'std::sort' declared here
 4863 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
shoes.cpp:15:16: error: expected primary-expression before 'int'
   15 |         vector<int> goal;
      |                ^~~
shoes.cpp:17:13: error: 'goal' was not declared in this scope
   17 |             goal.emplace_back(-i);
      |             ^~~~
shoes.cpp:20:16: error: expected primary-expression before 'bool'
   20 |         vector<bool> done(2*n);
      |                ^~~~
shoes.cpp:21:16: error: expected primary-expression before 'int'
   21 |         vector<int> arr;
      |                ^~~
shoes.cpp:25:22: error: 'done' was not declared in this scope
   25 |                 if (!done[j] && goal[j] == v[i]) {
      |                      ^~~~
shoes.cpp:25:33: error: 'goal' was not declared in this scope
   25 |                 if (!done[j] && goal[j] == v[i]) {
      |                                 ^~~~
shoes.cpp:25:44: error: 'v' was not declared in this scope
   25 |                 if (!done[j] && goal[j] == v[i]) {
      |                                            ^
shoes.cpp:29:13: error: 'done' was not declared in this scope
   29 |             done[j] = 1;
      |             ^~~~
shoes.cpp:30:13: error: 'arr' was not declared in this scope
   30 |             arr.emplace_back(j);
      |             ^~~
shoes.cpp:35:21: error: 'arr' was not declared in this scope
   35 |                 if (arr[j] > arr[i]) curr++;
      |                     ^~~
shoes.cpp:38:15: error: 'min' was not declared in this scope; did you mean 'std::min'?
   38 |         ans = min(ans, curr);
      |               ^~~
      |               std::min
In file included from /usr/include/c++/11/vector:62,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: 'std::min' declared here
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
shoes.cpp:39:14: error: 'next_permutation' was not declared in this scope; did you mean 'std::next_permutation'?
   39 |     } while (next_permutation(val.begin(), val.end()));
      |              ^~~~~~~~~~~~~~~~
      |              std::next_permutation
In file included from /usr/include/c++/11/vector:62,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:2985:5: note: 'std::next_permutation' declared here
 2985 |     next_permutation(_BidirectionalIterator __first,
      |     ^~~~~~~~~~~~~~~~