/**
* 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) {
int z = __lg(k);
vector<int> p;
for (int i = 0; i < z; ++i)p.push_back(i);
for (int i = z - 1; i >= 0; i--) {
if ((k >> i) & 1) {
p.insert(p.begin() + i, z++);
}
}
return p;
}
//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... |