Submission #1136056

#TimeUsernameProblemLanguageResultExecution timeMemory
1136056LudisseyPermutation (APIO22_perm)C++20
91.33 / 100
6 ms328 KiB
#include "perm.h" #include <bits/stdc++.h> #define int long long #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() using namespace std; vector<signed> construct_permutation(long long k) { k-=2; vector<int> sm(1000,0); vector<signed> v; sm[0]=1; v.push_back(0); int x=1; while(k>0){ for (int i = sz(v); i>=0; i--) { int s=1; for (int j = 0; j < i; j++) { if(v[j]<x) s+=sm[j]; } if(s<=k){ sm[x]+=s; v.insert(v.begin() + i, x); k-=s; break; } } x++; } return v; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...