# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
982742 | vjudge1 | Permutation (APIO22_perm) | C++17 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "perm.h"
#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repr(a,b,c) for(int a=b-1; a>c-1; a--)
#define repa(a,b) for(auto a:b)
#define fi first
#define se second
#define pii pair<int, int>
#define ll long long
#define pb push_back
using namespace std;
string s;
void solve(ll k){
if(k==1) return;
if(k&1){
s+='1';
solve(k-1);
}else{
s+='0';
solve(k/2);
}
}
vector<int> construct_permutation(long long k){
vector<int> perm;
s.clear();
solve(k);
int x=0, y=s.size()-1;
rep(i,0,s.size()){
if(s[i]=='1') perm.pb(x++);
else perm.pb(y--);
}
reverse(perm.begin(),perm.end());
return perm;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |