#include "perm.h"
#include<bits/stdc++.h>
using namespace std;
std::vector<int> construct_permutation(long long k)
{
deque<int> dq;
stack<bool> op;
while(k > 1){
if(k % 2 == 0){
op.push(0);
k /= 2;
}
else{
op.push(1);
k--;
}
}
int cur = 0;
while(!op.empty()){
int val = op.top();
op.pop();
if(val == 0) dq.push_back(cur++);
else dq.push_front(cur++);
}
vector<int> ret;
while(!dq.empty()){
ret.push_back(dq.front());
dq.pop_front();
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
340 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 |
340 KB |
Partially correct |
11 |
Partially correct |
1 ms |
340 KB |
Partially correct |
12 |
Partially correct |
2 ms |
340 KB |
Partially correct |
13 |
Partially correct |
2 ms |
340 KB |
Partially correct |