Submission #976115

#TimeUsernameProblemLanguageResultExecution timeMemory
976115rythm_of_knightPermutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
#include "perm.h" #include <vector> #include <algorithm> std::vector<int> construct_permutation(long long k) { #define int long long int temp = --k; vector <int> v; while (temp) { v.push_back(temp & 1); temp >>= 1; } int sz = v.size(); for (int i = 0; i < sz; i++) { while (i > 0 && v[i - 1] == 0 && v[i] > 0) { v[i - 1] += 2; v[i]--; i--; } } int cnt = -1; vector <int> ans; for (int i = 0; i < sz; i++) { vector <int> t; while (v[i]--) { t.push_back(++cnt); } reverse(t.begin(), t.end()); for (int &u : t) { ans.push_back(u); } } return ans; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:7:5: error: 'vector' was not declared in this scope
    7 |     vector <int> v;
      |     ^~~~~~
perm.cpp:7:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from perm.h:1,
                 from perm.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from perm.h:1,
                 from perm.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
perm.cpp:5:14: error: expected primary-expression before 'long'
    5 |  #define int long long
      |              ^~~~
perm.cpp:7:13: note: in expansion of macro 'int'
    7 |     vector <int> v;
      |             ^~~
perm.cpp:9:9: error: 'v' was not declared in this scope
    9 |         v.push_back(temp & 1);
      |         ^
perm.cpp:12:14: error: 'v' was not declared in this scope
   12 |     int sz = v.size();
      |              ^
perm.cpp:5:14: error: expected primary-expression before 'long'
    5 |  #define int long long
      |              ^~~~
perm.cpp:21:13: note: in expansion of macro 'int'
   21 |     vector <int> ans;
      |             ^~~
perm.cpp:5:14: error: expected primary-expression before 'long'
    5 |  #define int long long
      |              ^~~~
perm.cpp:23:17: note: in expansion of macro 'int'
   23 |         vector <int> t;
      |                 ^~~
perm.cpp:25:13: error: 't' was not declared in this scope
   25 |             t.push_back(++cnt);
      |             ^
perm.cpp:27:17: error: 't' was not declared in this scope
   27 |         reverse(t.begin(), t.end());
      |                 ^
perm.cpp:27:9: error: 'reverse' was not declared in this scope; did you mean 'std::reverse'?
   27 |         reverse(t.begin(), t.end());
      |         ^~~~~~~
      |         std::reverse
In file included from /usr/include/c++/10/algorithm:74,
                 from perm.cpp:3:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:249:1: note: 'std::reverse' declared here
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
perm.cpp:29:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |             ans.push_back(u);
      |             ^~~
      |             abs
perm.cpp:32:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |     return ans;
      |            ^~~
      |            abs