Submission #953656

#TimeUsernameProblemLanguageResultExecution timeMemory
953656De3b0oPermutation (APIO22_perm)C++17
71.22 / 100
11 ms1144 KiB
#include "perm.h" #include<bits/stdc++.h> #define ll long long #define F first #define S second #define in insert #define pb push_back #define ppb pop_back() #define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define cans cout << ans << "\n"; #define yes cout << "Yes" << "\n"; #define no cout << "No" << "\n"; #define pll pair<ll,ll> #define lin cout << "\n"; #define sqr 340 #define mod 1000000007 #define mid ((l+r)/2) //#define lc (2*n) //#define rc (2*n+1) using namespace std; ll fp(ll x , ll y) { if(y==0) return 1; ll z = fp(x,y/2); if(y&1) return z*z*x; else return z*z; } std::vector<int> construct_permutation(long long k) { vector<pll> v; ll p = 0; ll i = 0; k--; while(k>0) { ll x = fp(2,i-p); if(k<x) { v.pb({p,i-1}); p=i; continue; } if(k==x) { v.pb({p,i}); p=i; k=0; continue; } k-=x; i++; } vector<int> ans(p+1,0); ll x = 0; for(int i = v.size()-1 ; i>=0 ; i--) { for(int j = v[i].F ; v[i].S >=j ; j++) { ans[j]=x; x++; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...