Submission #1202078

#TimeUsernameProblemLanguageResultExecution timeMemory
1202078raul2008487Permutation (APIO22_perm)C++20
91.33 / 100
2 ms328 KiB
#include<bits/stdc++.h>
#include "perm.h"'
#define ll int
#define pb push_back
#define in insert
#define fi first
#define se second
#define vl vector<ll>
#define all(v) v.begin(), v.end()
#define endl '\n'
using namespace std;
void add(vl &a, ll pos, ll x){
    vl res;
    for(int i = 0; i < pos; i++){
        res.pb(a[i]);
    }
    res.pb(x);
    for(int i = pos; i < a.size(); i ++){
        res.pb(a[i]);
    }
    a = res;
}
vector<int> construct_permutation(long long k)
{
    ll l = __lg(k);
    vl ans;
    k -= (1ll << l);
    for(int i = 0; i < l; i++){
        ans.pb(i);
    }
    for(int i = l - 1; i >= 0; i--){
        if((k >> i) & 1){
            add(ans, i, l++);
        }
    }
    return ans;

}

Compilation message (stderr)

perm.cpp:2:18: warning: missing terminating ' character
    2 | #include "perm.h"'
      |                  ^
perm.cpp:2:18: warning: extra tokens at end of #include directive
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...