# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1049133 | Marco_Escandon | Permutation (APIO22_perm) | C++17 | 3 ms | 492 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
std::vector<int> construct_permutation(long long k)
{
vector<int> cad;
for(int i=0; i<64; i++)
{
cad.push_back(i);
}
ll k2=k;
ll p=64;
ll pl=0;
for(ll i=60; i>-1; i--)
{
if((k&(1LL<<i))!=0)
{
vector<int> cad2;
ll asdf=0;
for(int j=0; asdf<i-1+pl; j++)
{
if(cad[j]==asdf)
asdf++;
cad2.push_back(cad[j]);
}
cad2.push_back(p++);
for(int j=asdf; j<cad.size(); j++)
{
cad2.push_back(cad[j]);
}
cad=cad2;
pl=1;
}
}
while(cad.size()>0&&cad.back()!=64)
cad.pop_back();
vector<int> asd=cad;map<ll,ll> mapa;sort(asd.begin(),asd.end()); ll c=1;
for(auto i:asd)
if(mapa[i]==0)mapa[i]=c++;
for(int i=0; i<cad.size(); i++)
cad[i]=mapa[cad[i]]-1;
return cad;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |