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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
vector<int> construct_permutation(ll k){
vector<int> p;
int cc = 0;
if (k % 2){
p.pb(1e9);
p.pb(cc++);
k = (k - 1) / 2 - 1;
}
else {
p.pb(cc++);
k = k / 2 - 1;
}
while (k > 0){
cout<<"yo "<<k<<"\n";
if (k % 2){
p.pb(cc++);
k = (k - 1) / 2;
}
else {
// 0, 1, 2, 3 -> 15
//
// 9, 11, 13
if ((k + 1) % 3 == 0){
p.pb(cc + 1);
p.pb(cc);
cc += 2;
k = (k + 1) / 3 - 1;
continue;
}
if ((k + 1) % 5 == 0){
p.pb(cc + 2);
p.pb(cc);
p.pb(cc + 1);
cc += 3;
k = (k + 1) / 5 - 1;
continue;
}
if ((k + 1) % 9 == 0){
p.pb(cc + 1);
p.pb(cc + 0);
p.pb(cc + 3);
p.pb(cc + 2);
cc += 4;
k = (k + 1) / 9 - 1;
continue;
}
if ((k + 1) % 17 == 0){
p.pb(cc + 1);
p.pb(cc + 2);
p.pb(cc + 3);
p.pb(cc + 4);
p.pb(cc + 0);
cc += 5;
k = (k + 1) / 17 - 1;
continue;
}
if ((k + 1) % 33 == 0){
p.pb(cc + 1);
p.pb(cc + 2);
p.pb(cc + 3);
p.pb(cc + 4);
p.pb(cc + 5);
p.pb(cc + 0);
cc += 6;
k = (k + 1) / 33 - 1;
continue;
}
if ((k + 1) % 65 == 0){
p.pb(cc + 1);
p.pb(cc + 2);
p.pb(cc + 3);
p.pb(cc + 4);
p.pb(cc + 5);
p.pb(cc + 6);
p.pb(cc + 0);
cc += 7;
k = (k + 1) / 65 - 1;
continue;
}
p.pb(1e9);
p.pb(cc++);
k = k / 2 - 1;
}
}
for (int i = (int) p.size() - 1; i >= 0; i--){
if (p[i] == 1e9){
p[i] = cc++;
}
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |