Submission #897002

#TimeUsernameProblemLanguageResultExecution timeMemory
897002vjudge1Permutation (APIO22_perm)C++17
71.22 / 100
11 ms1444 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int N = 5e3+3, M = 2e2+2; const ll L = 62; vector<int> construct_permutation(ll k) { vector<int> p; if (!k) return p; k--; int r = N; //vector<int> p2; for (int j = L; j > 0; j--) { //cerr << k << " " << j << " " << (1ll << j) << " " << (1ll << j) - 1ll << endl; if (k >= (1ll << j) - 1ll) { k -= (1ll << j) - 1ll; for (int l = 1; l <= j; l++) { /*p2*/p.push_back(r-j+l); } //cerr << j << endl; r -= j; j = L+1; } } /*if (p.empty() || p2.size() < p.size()) swap(p, p2); }*/ int sz = p.size(); for (int i = 0; i < sz; i++) { p[i] -= N-sz+1; } return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...