Submission #720630

#TimeUsernameProblemLanguageResultExecution timeMemory
720630stevancvPermutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "perm.h" #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 1e5 + 2; const int inf = 1e9; ll C(ll a, ll b) { return (a + b - 1) / b; } vector<int> construct_permulation(ll k) { if (k <= 90) { vector<int> ret(k - 1); for (int i = 0; i < k - 1; i++) ret[i] = k - 2 - i; return ret; } int n = 120; vector<int> ret(n); for (int i = 0; i < n; i++) ret[i] = n - 1 - i; k -= n + 1; ll prv = n; for (int i = n - 1; i >= 0 && k; i--) { ll e = n - i; ll j = i; smin(j, C(k, 1ll << (e - 1))); if (k % (1ll << e) == 0 && j % 2 != 0) j -= 1; if (k % (1ll << e) != 0 && j % 2 == 0) j -= 1; if ((j + prv) % 2 == 0) smin(j, prv - 2); else smin(j, prv - 1); prv = j; for (int p = n - 1; p > n - 1 - j; p--) swap(ret[p], ret[p - 1]); k -= (1ll << (e - 1)) * j; } return ret; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccXqvH1b.o: in function `main':
grader.cpp:(.text.startup+0x240): undefined reference to `construct_permutation(long long)'
collect2: error: ld returned 1 exit status