Submission #579794

# Submission time Handle Problem Language Result Execution time Memory
579794 2022-06-19T21:48:31 Z peuch Permutation (APIO22_perm) C++17
91.3333 / 100
2 ms 340 KB
#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