Submission #603036

#TimeUsernameProblemLanguageResultExecution timeMemory
603036tutisPermutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
#include "perm.h" using namespace std; #include <iostream> #include <random> #include <functional> #include <map> using ll = long long; std::vector<int> construct_permutation(long long k, bool v) { if (k > 100) { if (k % 2 == 0) { vector<int>a = construct_permutation(k / 2, v); a.push_back((int)a.size()); return a; } if (k % 4 == 3 && k > 1000) { vector<int>a = construct_permutation(k - 3, true); for (int &i : a) if (i >= 2) i++; a.push_back(2); return a; } if (k % 2 == 1 && k > 1000) { vector<int>a = construct_permutation(k - 1, v); for (int &i : a) if (i >= 0) i++; a.push_back(0); return a; } } vector<int>ret = { -1}; vector<ll>dp = {1}; if (v) { assert(k >= 3); vector<int>ret = { -1, 1, 0}; vector<ll>dp = {1, 1, 1}; } for (int i : dp) k -= i; while (k != 0) { int sz = (int)ret.size(); for (int i = sz - 1; i >= 0; i--) { ll sum = 0; for (int j = 0; j < (int)ret.size(); j++) if (ret[j] < i) sum += dp[j]; if (sum <= k) { k -= sum; dp.push_back(sum); for (int &j : ret) if (j >= i) j++; ret.push_back(i); break; } } } ret.erase(ret.begin()); return ret; } vector<int> construct_permutation(long long k) { return construct_permutation(k, false); }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int, bool)':
perm.cpp:41:3: error: 'assert' was not declared in this scope
   41 |   assert(k >= 3);
      |   ^~~~~~
perm.cpp:7:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    6 | #include <map>
  +++ |+#include <cassert>
    7 | using ll = long long;