Submission #1352965

#TimeUsernameProblemLanguageResultExecution timeMemory
1352965cpdreamerPermutation (APIO22_perm)C++20
0 / 100
0 ms360 KiB
#include "perm.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long INF = 1e17;
typedef long long ll;
const ll MOD = 998244353;
#define F first
#define pb push_back
#define S second
#define P pair
#define V vector
#define all(v) v.begin(), v.end()
int  mx(ll n) {
    int maxd=0;
    for (int i=0;i<60;i++) {
        if (((1LL<<i)&n)!=0) {
            maxd=i;
        }
    }
    return maxd;
}
std::vector<int> construct_permutation(long long k)
{
    ll x=k;
    V<int>v;
    ll id=-1;
    for (ll i=63;i>=0;i--) {
        if (((1LL<<i)&x)!=0) {
            id=i;
            for (int j=0;j<i;j++) {
                v.pb(2*j);
            }
            break;
        }
    }
    for (ll i=id-1;i>=0;i--) {
        if (((1LL<<i)&x)!=0) {
            int val=-1;
            for ( ll j=0;j<i;j++) {
                val=v[j]+1;
            }
            v.pb(val);
        }
    }
    return v;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...