Submission #976112

# Submission time Handle Problem Language Result Execution time Memory
976112 2024-05-06T07:50:34 Z rythm_of_knight Permutation (APIO22_perm) C++17
Compilation error
0 ms 0 KB
#include "perm.h"
#include <bits/stdc++.h>
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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:6:5: error: 'vector' was not declared in this scope
    6 |     vector <int> v;
      |     ^~~~~~
perm.cpp:6: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:4:14: error: expected primary-expression before 'long'
    4 |  #define int long long
      |              ^~~~
perm.cpp:6:13: note: in expansion of macro 'int'
    6 |     vector <int> v;
      |             ^~~
perm.cpp:8:9: error: 'v' was not declared in this scope
    8 |         v.push_back(temp & 1);
      |         ^
perm.cpp:11:14: error: 'v' was not declared in this scope
   11 |     int sz = v.size();
      |              ^
perm.cpp:4:14: error: expected primary-expression before 'long'
    4 |  #define int long long
      |              ^~~~
perm.cpp:20:13: note: in expansion of macro 'int'
   20 |     vector <int> ans;
      |             ^~~
perm.cpp:4:14: error: expected primary-expression before 'long'
    4 |  #define int long long
      |              ^~~~
perm.cpp:22:17: note: in expansion of macro 'int'
   22 |         vector <int> t;
      |                 ^~~
perm.cpp:24:13: error: 't' was not declared in this scope
   24 |             t.push_back(++cnt);
      |             ^
perm.cpp:26:17: error: 't' was not declared in this scope
   26 |         reverse(t.begin(), t.end());
      |                 ^
perm.cpp:26:9: error: 'reverse' was not declared in this scope; did you mean 'std::reverse'?
   26 |         reverse(t.begin(), t.end());
      |         ^~~~~~~
      |         std::reverse
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from perm.cpp:2:
/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:28:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |             ans.push_back(u);
      |             ^~~
      |             abs
perm.cpp:31:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |     return ans;
      |            ^~~
      |            abs