# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
638484 | minhnhatnoe | Permutation (APIO22_perm) | C++17 | 2 ms | 340 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>
typedef long long ll;
using namespace std;
vector<int> construct_permutation(long long k){
deque<long double> a;
ll val = 63 - __builtin_clzll(k);
for (ll i=0; i<val; i++){
a.push_back(i+1);
}
for (ll i=val-1; i>=0; i--){
if ((k & (1LL<<i)) == 0) continue;
a.push_front(a[a.size() - i - 1] + 0.5);
}
// for (int i=0; i<a.size(); i++){
// cout << a[i] << " ";
// }
// cout << "\n";
deque<long double> b = a;
sort(b.begin(), b.end());
vector<int> result(a.size());
for (int i=0; i<a.size(); i++){
result[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin() ;
// cout << result[i] << " ";
}
// cout << endl;
return result;
}
// signed main(){
// construct_permutation(0b11);
// }
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |