#include "perm.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
vector<int> construct_permutation(ll k)
{
vector<int>v, b;
while(k)
{
b.pb(k%4);
k/=4;
}
reverse(b.begin(), b.end());
if(b[0]==2) v.pb(0);
else if(b[0]==3) v={1, 0};
for(int i=1; i<(int)b.size(); i++)
{
if(b[i]==0)
{
v.pb(1e9);
v.pb(1e9+1);
}
else if(b[i]==1)
{
v.pb(1e9);
v.pb(1e9+1);
v.pb(-1);
}
else if(b[i]==2)
{
v.pb(1e9);
v.pb(-1);
v.pb(1e9+1);
}
else
{
int flag=0;
for(int u : v)
{
if(u==flag)
flag++;
}
if(flag>=2 or v.size()<2)
{
v.pb(1e9);
v.pb(-1);
v.pb(1e9+1);
v.pb(-2);
}
else
{
for(int j=0; j<(int)v.size(); j++)
v[j]<<=1;
v.pb(1e9);
v.pb(1e9+1);
v.pb(3);
}
}
vector<int>cur;
cur=v;
for(int j=0; j<(int)v.size(); j++)
{
int cnt=0;
for(int u : cur)
{
if(u<v[j]) cnt++;
}
v[j]=cnt;
}
}
return v;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
4 ms |
340 KB |
Output is correct |
8 |
Correct |
6 ms |
300 KB |
Output is correct |
9 |
Correct |
3 ms |
340 KB |
Output is correct |
10 |
Correct |
6 ms |
300 KB |
Output is correct |
11 |
Correct |
5 ms |
340 KB |
Output is correct |
12 |
Correct |
4 ms |
300 KB |
Output is correct |
13 |
Correct |
5 ms |
340 KB |
Output is correct |