#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int32_t> construct_permutation(int k)
{
int dv = 1;
deque<int> ans;
if(k%3 == 0) {
k/=3;
dv = 3;
}
else if(k%5 == 0) {
k/=5;
dv = 5;
}
int lg = 0;
for(int i = 0; i <= 60; i++) {
if(k >= (1LL<<i)) lg = i;
}
for(int i = lg-1; i >= 0; i--) {
ans.push_back((int) ans.size());
if(k&(1LL<<i)) ans.push_front((int) ans.size());
}
//adiociona algo que multiplica por 3 agora
if(dv == 3) {
ans.push_back((int) ans.size()+1);
ans.push_back((int) ans.size()-1);
}
if(dv == 5) {
int x = ans.size();
ans.push_back(x+2);
ans.push_back(x);
ans.push_back(x+1);
}
vector<int32_t> vc;
for(auto x : ans) {
vc.push_back(x);
}
return vc;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Partially correct |
1 ms |
344 KB |
Partially correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Partially correct |
2 ms |
340 KB |
Partially correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Partially correct |
2 ms |
308 KB |
Partially correct |
11 |
Partially correct |
1 ms |
340 KB |
Partially correct |
12 |
Partially correct |
2 ms |
340 KB |
Partially correct |
13 |
Partially correct |
1 ms |
340 KB |
Partially correct |