/**
* In the name of Allah
* We are nothing and you're everything
**/
#include <bits/stdc++.h>
//#include "swap.h"
#include "perm.h"
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
//#define int ll
const char nl = '\n';
const int N = 3e5+10;
const int inf = 1e9;
vector<int> construct_permutation(long long k) {
deque<int> ans;
int start = 0, cnt = 0;
for (int i = 0; i <= 60; ++i) {
if ((1ll << i)&k) {
cnt += 1;
for (int j = i-1; j >= 0; --j)
ans.push_front(j+start);
start += i;
}
}
for (int j = 0; j <= cnt-2; ++j)
ans.push_front(j+start);
vector<int> a;
for (auto i: ans)a.push_back(i);
return a;
}
//int calc(vector<int> &c) {
//int n = sz(c), sum = 0;
//for (int i = 0; i < (1 << n); ++i) {
//int onki = -1; bool ok = true;
//for (int j = n-1; j >= 0; --j)
//if ((i & j) > 0) {
//if (j >= onki){ok = false; break; }
//onki = j;
//}
//if (ok)sum += 1;
//if (ok) {
//for (int j = n-1; j >= 0; --j)
//if ((i & j) > 0)cout << c[j] << " ";
//cout << nl;
//}
//}
//return sum;
//}
//int main() {
//ll k; cin >> k;
//vector<int> a = construct_permutation(k);
//for (auto i: a)cout << i << " ";
//return 0;
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |