Submission #741585

#TimeUsernameProblemLanguageResultExecution timeMemory
741585shantolPermutation (APIO22_perm)C++17
100 / 100
8 ms368 KiB
#include "perm.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define sz size() #define pb push_back #define lb lower_bound #define all(x) x.begin(),x.end() vector<int> construct_permutation(ll k){ int bit=64-__builtin_clzll(k); vector<double> ans; bool flag=false; while(bit>0){ bit-=2; if(bit==-1){ ans.pb(100); if(k&1)ans.pb(-100); } else{ int val=(k>>bit)&3; if(ans.empty()){ if(val==2) ans.pb(0); else ans={1,0},flag=true; continue; } if(val==0){ ans.pb(100); ans.pb(101); } else if(val==1){ ans.pb(100); ans.pb(101); ans.pb(-100); flag=true; } else if(val==2){ ans.pb(100); ans.pb(-100); ans.pb(101); flag=true; } else{ if(!flag){ ans.pb(100); ans.pb(-100); ans.pb(101); ans.pb(-101); flag=true; } else{ ans.pb(100); ans.pb(101); ans.pb(1.5); } } } vector<double> uni(all(ans)); sort(all(uni)); for(auto &i:ans)i=lb(all(uni),i)-uni.begin(); } return vector<int> (all(ans)); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...